+2008-05-04 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/35990
+ * gfortran.dg/intrinsic_pack_4.f90: New test case.
+
2008-05-03 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr6_pkg.ads: New helper.
--- /dev/null
+! { dg-do run }
+! PR 35990 - some empty array sections caused pack to crash.
+! Test case contributed by Dick Hendrickson, adjusted and
+! extended by Thomas Koenig.
+ program try_gf1048
+
+ call gf1048a( 10, 8, 7, 1, 0, .true.)
+ call gf1048b( 10, 8, 7, 1, 0, .true.)
+ call gf1048c( 10, 8, 7, 1, 0, .true.)
+ call gf1048d( 10, 8, 7, 1, 0, .true.)
+ call P_inta ( 10, 8, 7, 1, 0, .true.)
+ call P_intb ( 10, 8, 7, 1, 0, .true.)
+ call P_intc ( 10, 8, 7, 1, 0, .true.)
+ call P_intd ( 10, 8, 7, 1, 0, .true.)
+ end program
+
+ SUBROUTINE GF1048a(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ CHARACTER(9) BDA(10)
+ CHARACTER(9) BDA1(10)
+ BDA( 8:7) = PACK(BDA1( 10: 1), NF_TRUE)
+ END SUBROUTINE
+
+ SUBROUTINE GF1048b(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ CHARACTER(9) BDA(10)
+ CHARACTER(9) BDA1(nf10)
+ BDA(NF8:NF7) = PACK(BDA1(NF8:NF7), NF_TRUE)
+ END SUBROUTINE
+
+ SUBROUTINE GF1048c(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ CHARACTER(9) BDA(10)
+ CHARACTER(9) BDA1(10)
+ BDA(NF8:NF7) = PACK(BDA1(NF10:NF1), NF_TRUE)
+ END SUBROUTINE
+
+ SUBROUTINE GF1048d(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ CHARACTER(9) BDA(10)
+ CHARACTER(9) BDA1(nf10)
+ BDA(NF8:NF7) = PACK(BDA1(NF10:NF1), NF_TRUE)
+ END SUBROUTINE
+
+ SUBROUTINE P_INTa(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ INTEGER BDA(10)
+ INTEGER BDA1(10)
+ BDA( 8:7) = PACK(BDA1( 10: 1), NF_TRUE)
+ END SUBROUTINE
+
+ SUBROUTINE P_INTb(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ INTEGER BDA(10)
+ INTEGER BDA1(nf10)
+ BDA(NF8:NF7) = PACK(BDA1(NF8:NF7), NF_TRUE)
+ END SUBROUTINE
+
+ SUBROUTINE P_INTc(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ INTEGER BDA(10)
+ INTEGER BDA1(10)
+ BDA(NF8:NF7) = PACK(BDA1(NF10:NF1), NF_TRUE)
+ END SUBROUTINE
+
+ SUBROUTINE P_INTd(nf10,nf8,nf7,nf1,nf0,nf_true)
+ logical nf_true
+ INTEGER BDA(10)
+ INTEGER BDA1(nf10)
+ BDA(NF8:NF7) = PACK(BDA1(NF10:NF1), NF_TRUE)
+ END SUBROUTINE
+
+2008-05-04 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/35990
+ * intrinsics/pack_generic.c: If an extent of the source
+ array is less then zero, set it to zero. Set the source
+ pointer to NULL if the source size is zero. Set the total
+ number of elements to zero if the vector has an extent
+ less or equal to zero.
+ * m4/pack.m4: Set the source pointer to NULL if the
+ source array is zero-sized. Set the total number of
+ elemements to zero if the vector has an extent less or
+ equal to zero.
+ * generated/pack_i1.c: Regenerated.
+ * generated/pack_i2.c: Regenerated.
+ * generated/pack_i4.c: Regenerated.
+ * generated/pack_i8.c: Regenerated.
+ * generated/pack_i16.c: Regenerated.
+ * generated/pack_r4.c: Regenerated.
+ * generated/pack_r8.c: Regenerated.
+ * generated/pack_r10.c: Regenerated.
+ * generated/pack_r16.c: Regenerated.
+ * generated/pack_c4.c: Regenerated.
+ * generated/pack_c8.c: Regenerated.
+ * generated/pack_c10.c: Regenerated.
+ * generated/pack_c16.c: Regenerated.
+
2008-05-01 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/36094
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
+
dim = GFC_DESCRIPTOR_RANK (array);
- sptr = array->data;
mptr = mask->data;
/* Use the same loop for all logical types, by using GFC_LOGICAL_1
if (mstride[0] == 0)
mstride[0] = mask_kind;
+ if (zero_sized)
+ sptr = NULL;
+ else
+ sptr = array->data;
+
if (ret->data == NULL || compile_options.bounds_check)
{
/* Count the elements, either for allocating memory or
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
+ if (total < 0)
+ {
+ total = 0;
+ vector = NULL;
+ }
}
else
{
}
#endif
-'
\ No newline at end of file
+'