2014-08-15 Thomas Koenig <tkoenig@gcc.gnu.org>
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Aug 2014 21:19:33 +0000 (21:19 +0000)
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Aug 2014 21:19:33 +0000 (21:19 +0000)
PR fortran/62142
* trans-expr.c (is_runtime_conformable):  Add NULL pointer checks.

2014-08-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/62142
* gfortran.dg/realloc_on_assign_24.f90:  New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214043 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/realloc_on_assign_24.f90 [new file with mode: 0644]

index fcf591c..ec126b9 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-15  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/62142
+       * trans-expr.c (is_runtime_conformable):  Add NULL pointer checks.
+
 2014-08-15  Tobias Burnus  <burnus@net-b.de>
 
        * resolve.c (resolve_critical): Fix name mangling.
index 544fc76..2ea09ce 100644 (file)
@@ -7897,7 +7897,7 @@ is_runtime_conformable (gfc_expr *expr1, gfc_expr *expr2)
          for (a = expr2->value.function.actual; a != NULL; a = a->next)
            {
              e1 = a->expr;
-             if (e1->rank > 0 && !is_runtime_conformable (expr1, e1))
+             if (e1 && e1->rank > 0 && !is_runtime_conformable (expr1, e1))
                return false;
            }
          return true;
@@ -7908,7 +7908,7 @@ is_runtime_conformable (gfc_expr *expr1, gfc_expr *expr2)
          for (a = expr2->value.function.actual; a != NULL; a = a->next)
            {
              e1 = a->expr;
-             if (e1->rank > 0 && !is_runtime_conformable (expr1, e1))
+             if (e1 && e1->rank > 0 && !is_runtime_conformable (expr1, e1))
                return false;
            }
          return true;
index 3f19ce7..5c40c0e 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-15  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/62142
+       * gfortran.dg/realloc_on_assign_24.f90:  New test.
+
 2014-08-15  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/62072
diff --git a/gcc/testsuite/gfortran.dg/realloc_on_assign_24.f90 b/gcc/testsuite/gfortran.dg/realloc_on_assign_24.f90
new file mode 100644 (file)
index 0000000..6f88c2b
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR 62142 - this used to segfault
+! Original test case by Ondřej Čertík .
+program test_segfault
+  implicit none
+  real, allocatable :: X(:)
+  allocate (x(1))
+  x = 1.
+  X = floor(X)
+end program