mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-05 17:00:58 +08:00
re PR libfortran/31001 ([4.1 only] PACK crashes on zero-sized arrays)
PR libfortran/31001 * intrinsics/pack_generic.c (pack_internal): Add special checks for zero-sized arrays. * gfortran.dg/zero_sized_3.f90: New test. From-SVN: r122507
This commit is contained in:
parent
4e09692de3
commit
42d53ef301
@ -1,3 +1,8 @@
|
||||
2007-03-03 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
||||
|
||||
PR libfortran/31001
|
||||
* gfortran.dg/zero_sized_3.f90: New test.
|
||||
|
||||
2007-03-03 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/15787
|
||||
|
20
gcc/testsuite/gfortran.dg/zero_sized_3.f90
Normal file
20
gcc/testsuite/gfortran.dg/zero_sized_3.f90
Normal file
@ -0,0 +1,20 @@
|
||||
! { dg-do run }
|
||||
! Testcase for PR libfortran/31001
|
||||
implicit none
|
||||
|
||||
integer :: i, j, k
|
||||
integer, allocatable :: mm(:)
|
||||
logical, allocatable :: mask(:)
|
||||
|
||||
do i = 2, -2, -1
|
||||
do k = 0, 1
|
||||
allocate (mm(i), mask(i))
|
||||
mm(:) = k
|
||||
mask(:) = (mm == 0)
|
||||
j = count (mask)
|
||||
print *, pack (mm, mask)
|
||||
if (size (pack (mm, mask)) /= j) call abort
|
||||
deallocate (mm, mask)
|
||||
end do
|
||||
end do
|
||||
end
|
@ -1,3 +1,9 @@
|
||||
2007-03-03 Francois-Xavier Coudert <coudert@clipper.ens.fr>
|
||||
|
||||
PR libfortran/31001
|
||||
* intrinsics/pack_generic.c (pack_internal): Add special checks
|
||||
for zero-sized arrays.
|
||||
|
||||
2007-03-01 Brooks Moses <brooks.moses@codesourcery.com>
|
||||
|
||||
* Makefile.am: Add dummy install-pdf target.
|
||||
|
@ -93,15 +93,19 @@ pack_internal (gfc_array_char *ret, const gfc_array_char *array,
|
||||
|
||||
index_type count[GFC_MAX_DIMENSIONS];
|
||||
index_type extent[GFC_MAX_DIMENSIONS];
|
||||
int zero_sized;
|
||||
index_type n;
|
||||
index_type dim;
|
||||
index_type nelem;
|
||||
|
||||
dim = GFC_DESCRIPTOR_RANK (array);
|
||||
zero_sized = 0;
|
||||
for (n = 0; n < dim; n++)
|
||||
{
|
||||
count[n] = 0;
|
||||
extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
|
||||
if (extent[n] <= 0)
|
||||
zero_sized = 1;
|
||||
sstride[n] = array->dim[n].stride * size;
|
||||
mstride[n] = mask->dim[n].stride;
|
||||
}
|
||||
@ -154,6 +158,8 @@ pack_internal (gfc_array_char *ret, const gfc_array_char *array,
|
||||
const GFC_LOGICAL_4 *m = mptr;
|
||||
|
||||
total = 0;
|
||||
if (zero_sized)
|
||||
m = NULL;
|
||||
|
||||
while (m)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user