re PR fortran/42268 (derived type segfault with pack)

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

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


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

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

From-SVN: r155139
This commit is contained in:
Janus Weil 2009-12-10 21:28:57 +01:00
parent 278d4b3b33
commit 84899e7df6
4 changed files with 31 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2009-12-10 Janus Weil <janus@gcc.gnu.org>
PR fortran/42268
* gfortran.dg/intrinsic_pack_5.f90: New test.
2009-12-04 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Backport from mainline:

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,9 @@
2009-12-10 Janus Weil <janus@gcc.gnu.org>
PR fortran/42268
* intrinsics/pack_generic.c (pack): Add safety checks for the case that
'vector' is NULL.
2009-11-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/42090

View File

@ -403,7 +403,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
{
@ -414,7 +414,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
{
@ -425,7 +425,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
{
@ -436,7 +436,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
{