+2008-07-21 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/36773
+ * gfortran.dg/zero_sized_5.f90: New test case.
+
2008-07-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/36870
--- /dev/null
+! { dg-do run }
+! These used to segfault.
+program main
+ real, dimension(1,0) :: a, b, c
+ integer, dimension(0) :: j
+ a = 0
+ c = 0
+ b = cshift (a,1)
+ b = cshift (a,j)
+ b = eoshift (a,1)
+ b = eoshift (a,(/1/))
+ b = eoshift (a,1,boundary=c(1,:))
+ b = eoshift (a, j, boundary=c(1,:))
+
+end program main
+2008-07-21 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/36773
+ * intrinsics/cshift0.c (cshift0): Return early if size of array
+ is zero.
+ * intrinsics/eoshift0.c (eoshift0): Return early if size of
+ return array is zero.
+ * intrinsics/eoshift2.c (eoshift2): Likewise.
+ * m4/eoshift1.m4 (eoshift1): Return early if size of array
+ is zero.
+ * m4/eoshift3.m4 (eoshift3): Likewise.
+ * m4/eoshift2.m4 (eoshift2): Return early if size of return
+ array is zero.
+ * m4/eoshift4.m4 (eoshift2): Return early if size of return
+ array is zero.
+ * generated/cshift1_16.c: Regenerated.
+ * generated/cshift1_4.c: Regenerated.
+ * generated/cshift1_8.c: Regenerated.
+ * generated/eoshift1_16.c: Regenerated.
+ * generated/eoshift1_4.c: Regenerated.
+ * generated/eoshift1_8.c: Regenerated.
+ * generated/eoshift3_16.c: Regenerated.
+ * generated/eoshift3_4.c: Regenerated.
+ * generated/eoshift3_8.c: Regenerated.
+
2008-07-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/36857
index_type n;
int which;
GFC_INTEGER_16 sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
index_type n;
int which;
GFC_INTEGER_4 sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
index_type n;
int which;
GFC_INTEGER_8 sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;
index_type len;
index_type n;
int whichloop;
+ index_type arraysize;
if (which < 1 || which > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *) array);
+
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->offset = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1)
+ * ret->dim[i-1].stride;
+ }
+
+ if (arraysize > 0)
+ ret->data = internal_malloc_size (size * arraysize);
+ else
+ {
+ ret->data = internal_malloc_size (1);
+ return;
+ }
+ }
+
+ if (arraysize == 0)
+ return;
+
which = which - 1;
sstride[0] = 0;
rstride[0] = 0;
soffset = size;
len = 0;
- if (ret->data == NULL)
- {
- int i;
- index_type arraysize = size0 ((array_t *)array);
-
- ret->offset = 0;
- ret->dtype = array->dtype;
- for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
- {
- ret->dim[i].lbound = 0;
- ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
-
- if (i == 0)
- ret->dim[i].stride = 1;
- else
- ret->dim[i].stride = (ret->dim[i-1].ubound + 1)
- * ret->dim[i-1].stride;
- }
-
- if (arraysize > 0)
- ret->data = internal_malloc_size (size * arraysize);
- else
- {
- ret->data = internal_malloc_size (1);
- return;
- }
- }
-
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
if (dim == which)
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
which = which - 1;
index_type dim;
index_type len;
index_type n;
+ index_type arraysize;
/* The compiler cannot figure out that these are set, initialize
them to avoid warnings. */
soffset = 0;
roffset = 0;
+ arraysize = size0 ((array_t *) array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
+
+ if (arraysize == 0 && filler == NULL)
+ return;
which = which - 1;
index_type n;
int which;
'atype_name` sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument ''`DIM''` is out of range in call to ''`CSHIFT''`");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;