]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/81735 (double free or corruption (fasttop) error (SIGABRT) with charact...
authorPaul Thomas <pault@gcc.gnu.org>
Fri, 3 Nov 2017 19:17:19 +0000 (19:17 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Fri, 3 Nov 2017 19:17:19 +0000 (19:17 +0000)
2017-11-03  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/81735
* trans-decl.c (gfc_trans_deferred_vars): Correct case where
'tmp' can be used unititialized.

2017-11-03  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/81735
* gfortran.dg/pr81735.f90: New test.

From-SVN: r254393

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

index 8d75d55b25636bb3307f05fa9adaf298c464a40f..1e5211109595ff3dd61daa5777964e07d591202f 100644 (file)
@@ -1,3 +1,10 @@
+2017-11-03  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from 7-branch
+       PR fortran/81735
+       * trans-decl.c (gfc_trans_deferred_vars): Correct case where
+       'tmp' can be used unititialized.
+
 2017-11-01  Andre Vehreschild  <vehre@gcc.gnu.org>
        Paul Thomas  <pault@gcc.gnu.org>
 
index 272ac57dd58c943917895b66a73491814e2afd60..36f882029e21e0c67546d536094d9e6aaf138be0 100644 (file)
@@ -4364,7 +4364,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                    && sym->ts.u.cl->passed_length)
                tmp = gfc_null_and_pass_deferred_len (sym, &init, &loc);
              else
-               gfc_restore_backend_locus (&loc);
+               {
+                 gfc_restore_backend_locus (&loc);
+                 tmp = NULL_TREE;
+               }
 
              /* Deallocate when leaving the scope. Nullifying is not
                 needed.  */
index 65728d7490170c451623d47cfb84ec5f3df87a0e..85087554b63d5cad0a79f235aebd51be909c30e7 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-03  Paul Thomas  <pault@gcc.gnu.org>
+
+       Backport from 7-branch
+       PR fortran/81735
+       * gfortran.dg/pr81735.f90: New test.
+
 2017-11-01  Paul Thomas  <pault@gcc.gnu.org>
 
        Backport from trunk
diff --git a/gcc/testsuite/gfortran.dg/pr81735.f90 b/gcc/testsuite/gfortran.dg/pr81735.f90
new file mode 100644 (file)
index 0000000..6aae203
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Contributed by Danila  <flashmozzg@gmail.com>
+!
+program fooprog
+    implicit none
+    type FooType
+        integer, allocatable :: x
+    end type FooType
+
+    type(FooType), pointer :: bar
+
+    bar => foo()
+
+contains
+    function foo() result(res)
+        type(FooType), pointer :: res
+
+        character(:), allocatable :: rt
+        rt = ""
+        res => null()
+    end function foo
+end program fooprog
+! { dg-final { scan-tree-dump-times "__builtin_free" 1 "original" } }