summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-04 10:14:49 +0000
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-04 10:14:49 +0000
commit10a2a3155989beb9d5128992243048288d096f80 (patch)
tree916b49d74e2b351e44cd9159b7487c6daebdecef /libgfortran
parent77d6d75eb7fe2bb68aee1f60c376ac6ed51680bc (diff)
downloadgcc-10a2a3155989beb9d5128992243048288d096f80.tar.gz
2008-05-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/35990 * intrinsics/pack_generic.c: Really commit. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134928 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog5
-rw-r--r--libgfortran/intrinsics/pack_generic.c16
2 files changed, 19 insertions, 2 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 89019b36f8a..ec9ab88b753 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,6 +1,11 @@
2008-05-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/35990
+ * intrinsics/pack_generic.c: Really commit.
+
+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
diff --git a/libgfortran/intrinsics/pack_generic.c b/libgfortran/intrinsics/pack_generic.c
index e282c916502..bb4abaeae4b 100644
--- a/libgfortran/intrinsics/pack_generic.c
+++ b/libgfortran/intrinsics/pack_generic.c
@@ -491,6 +491,7 @@ pack_s_internal (gfc_array_char *ret, const gfc_array_char *array,
index_type dim;
index_type ssize;
index_type nelem;
+ index_type total;
dim = GFC_DESCRIPTOR_RANK (array);
ssize = 1;
@@ -498,6 +499,9 @@ pack_s_internal (gfc_array_char *ret, const gfc_array_char *array,
{
count[n] = 0;
extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ if (extent[n] < 0)
+ extent[n] = 0;
+
sstride[n] = array->dim[n].stride * size;
ssize *= extent[n];
}
@@ -505,18 +509,26 @@ pack_s_internal (gfc_array_char *ret, const gfc_array_char *array,
sstride[0] = size;
sstride0 = sstride[0];
- sptr = array->data;
+
+ if (ssize != 0)
+ sptr = array->data;
+ else
+ sptr = NULL;
if (ret->data == NULL)
{
/* Allocate the memory for the result. */
- int total;
if (vector != NULL)
{
/* 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
{