With gcc 4.0.0 20050119 on powerpc-apple-darwin7.7.0 (Dual G5 mac running Mac OS X 10.3.7) and GCC configured with: /Users/nburrell/Desktop/gcc-4.0-cvs/gcc/configure --with-mpfr=/Users/ nburrell/usr --with-gmp=/Users/nburrell/usr --prefix=/Users/nburrell/usr --enable- languages=c,f95 running the command gfortran -Wall -v -save-temps test_gfortran.f90 gives the following output: nburrell@braeburn[~/isis_home/research/pvsim/test]$ gfortran -Wall -v -save-temps test_gfortran.f90 Driving: gfortran -Wall -v -save-temps test_gfortran.f90 -lgfortranbegin -lgfortran -shared-libgcc Using built-in specs. Configured with: /Users/nburrell/Desktop/gcc-4.0-cvs/gcc/configure --with-mpfr=/Users/nburrell/ usr --with-gmp=/Users/nburrell/usr --prefix=/Users/nburrell/usr --enable-languages=c,f95 Thread model: posix gcc version 4.0.0 20050119 (experimental) /Users/nburrell/usr/libexec/gcc/powerpc-apple-darwin7.7.0/4.0.0/f951 test_gfortran.f90 -fPIC -quiet -dumpbase test_gfortran.f90 -auxbase test_gfortran -Wall -version -o test_gfortran.s GNU F95 version 4.0.0 20050119 (experimental) (powerpc-apple-darwin7.7.0) compiled by GNU C version 4.0.0 20050118 (experimental). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 test_gfortran.f90: In function 'set_value': test_gfortran.f90:15: internal compiler error: in gfc_conv_variable, at fortran/trans-expr.c:317 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. where test_gfortran.f90 has the following contents: MODULE random_standard_normal_mod IMPLICIT NONE CONTAINS FUNCTION random_standard_normal() IMPLICIT NONE REAL :: y REAL :: random_standard_normal y = 4. CALL set_value RETURN CONTAINS SUBROUTINE set_value IMPLICIT NONE random_standard_normal = y END SUBROUTINE set_value END FUNCTION random_standard_normal END MODULE random_standard_normal_mod
Confirmed.
Shorter testcase: function f integer :: f contains subroutine sub f = 1 end subroutine sub end function f
*** Bug 23962 has been marked as a duplicate of this bug. ***
Corrected testcase: function f() integer :: f contains subroutine sub f = 1 end subroutine sub end function f The ICE is now at: t.f90:4: internal compiler error: in gfc_conv_variable, at fortran/trans-expr.c:354
A patch is on its way in the next 48 hours - I have it working with no regressions; it needs tidying up and a full set of testcases writing. Paul
(In reply to comment #5) > A patch is on its way in the next 48 hours - I have it working with no > regressions; it needs tidying up and a full set of testcases writing. "Tidying up" proved to be a bit bloody once I latched onto entries.... *sigh* The patch has been submitted a few minutes ago. Paul
Subject: Bug 19546 Author: pault Date: Mon Mar 6 22:56:39 2006 New Revision: 111793 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111793 Log: 2006-03-06 Paul Thomas <pault@gcc.gnu.org> PR fortran/26107 * resolve.c (resolve_function): Add name after test for pureness. PR fortran/19546 * trans-expr.c (gfc_conv_variable): Detect reference to parent result, store current_function_decl, replace with parent, whilst calls are made to gfc_get_fake_result_decl, and restore afterwards. Signal this to gfc_get_fake_result_decl with a new argument, parent_flag. * trans-stmt.c (gfc_trans_return): gfc_get_fake_result_decl 2nd arg is set to zero. * trans.h: Add parent_flag to gfc_get_fake_result_decl prototype. * trans-decl.c (gfc_get_fake_result_decl): On parent_flag, being set, add decl to parent function. Replace refs to current_fake_result_decl with refs to this_result_decl. (gfc_generate_function_code): Null parent_fake_result_decl before the translation of code for contained procedures. Set parent_flag to zero in call to gfc_get_fake_result_decl. * trans-intrinsic.c (gfc_conv_intrinsic_len): The same. 2006-03-06 Paul Thomas <pault@gcc.gnu.org> PR fortran/26107 * pure_dummy_length_1.f90: New test. PR fortran/19546 * gfortran.dg/parent_result_ref_1.f90: New test. * gfortran.dg/parent_result_ref_2.f90: New test. * gfortran.dg/parent_result_ref_3.f90: New test. * gfortran.dg/parent_result_ref_4.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/parent_result_ref_1.f90 trunk/gcc/testsuite/gfortran.dg/parent_result_ref_2.f90 trunk/gcc/testsuite/gfortran.dg/parent_result_ref_3.f90 (with props) trunk/gcc/testsuite/gfortran.dg/parent_result_ref_4.f90 trunk/gcc/testsuite/gfortran.dg/pure_dummy_length_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/fortran/trans-decl.c trunk/gcc/fortran/trans-expr.c trunk/gcc/fortran/trans-intrinsic.c trunk/gcc/fortran/trans-openmp.c trunk/gcc/fortran/trans-stmt.c trunk/gcc/fortran/trans.h trunk/gcc/testsuite/ChangeLog Propchange: trunk/gcc/testsuite/gfortran.dg/parent_result_ref_3.f90 ('svn:executable' added)
This will only be fixed on 4.2. The 4.1 and 4.2 trees have diverged so much in gfc_get_fake_result_decl that it will be a lot of work to bring it up to the point where it will take the patch for this PR. Paul