re PR fortran/41478 (Corrupted memory using PACK for derived-types with allocated components)

libgfortran/
2009-12-06  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41478
	PR fortran/42268
	* intrinsics/pack_generic.c (pack): Add safety checks for the case that
	'vector' is NULL.


gcc/testsuite/
2009-12-06  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41478
	PR fortran/42268
	* gfortran.dg/intrinsic_pack_5.f90: New test.

From-SVN: r155024
This commit is contained in:
Janus Weil 2009-12-06 23:57:13 +01:00
parent 3a5729ea2a
commit a15b72fa7f
4 changed files with 33 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2009-12-06 Janus Weil <janus@gcc.gnu.org>
PR fortran/41478
PR fortran/42268
* gfortran.dg/intrinsic_pack_5.f90: New test.
2009-12-04 Jason Merrill <jason@redhat.com>
PR c++/42010

View File

@ -0,0 +1,16 @@
! { dg-do run }
!
! PR 41478: Corrupted memory using PACK for derived-types with allocated components
! PR 42268: [4.4/4.5 Regression] derived type segfault with pack
!
! Original test case by Juergen Reuter <reuter@physik.uni-freiburg.de>
! Modified by Janus Weil <janus@gcc.gnu.org>
type :: container_t
integer:: entry = -1
end type container_t
type(container_t), dimension(1) :: a1, a2
a2(1)%entry = 1
a1 = pack (a2, mask = [.true.])
if (a1(1)%entry/=1) call abort()
end

View File

@ -1,3 +1,10 @@
2009-12-06 Janus Weil <janus@gcc.gnu.org>
PR fortran/41478
PR fortran/42268
* intrinsics/pack_generic.c (pack): Add safety checks for the case that
'vector' is NULL.
2009-12-05 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* Makefile.in: Regenerate.

View File

@ -346,7 +346,7 @@ pack (gfc_array_char *ret, const gfc_array_char *array,
case GFC_DTYPE_DERIVED_2:
if (GFC_UNALIGNED_2(ret->data) || GFC_UNALIGNED_2(array->data)
|| GFC_UNALIGNED_2(vector->data))
|| (vector && GFC_UNALIGNED_2(vector->data)))
break;
else
{
@ -357,7 +357,7 @@ pack (gfc_array_char *ret, const gfc_array_char *array,
case GFC_DTYPE_DERIVED_4:
if (GFC_UNALIGNED_4(ret->data) || GFC_UNALIGNED_4(array->data)
|| GFC_UNALIGNED_4(vector->data))
|| (vector && GFC_UNALIGNED_4(vector->data)))
break;
else
{
@ -368,7 +368,7 @@ pack (gfc_array_char *ret, const gfc_array_char *array,
case GFC_DTYPE_DERIVED_8:
if (GFC_UNALIGNED_8(ret->data) || GFC_UNALIGNED_8(array->data)
|| GFC_UNALIGNED_8(vector->data))
|| (vector && GFC_UNALIGNED_8(vector->data)))
break;
else
{
@ -379,7 +379,7 @@ pack (gfc_array_char *ret, const gfc_array_char *array,
#ifdef HAVE_GFC_INTEGER_16
case GFC_DTYPE_DERIVED_16:
if (GFC_UNALIGNED_16(ret->data) || GFC_UNALIGNED_16(array->data)
|| GFC_UNALIGNED_16(vector->data))
|| (vector && GFC_UNALIGNED_16(vector->data)))
break;
else
{