http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50050

             Bug #: 50050
           Summary: Internal compiler error free_expr0 at expr.c:3709 via
                    gfc_done_2
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: sigur...@gmail.com


Created attachment 24988
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24988
Trigger bug with "gfortran bug.f90"

The attached minimal program triggers an internal compiler bug in all versions
of gfortran I have encountered. That includes

GNU Fortran (GCC) 4.7.0 20110811 (experimental) - linux 2.6.32-33 - ubuntu
GNU Fortran (GCC) 4.7.0 20110713 (experimental) - linux 2.6.18-238 - red hat 5
GNU Fortran (GCC) 4.6.0 - linux 2.6.32-33 - ubuntu
GNU Fortran (Gentoo 4.5.3 p1.0, pie-0.4.5) 4.5.3
GNU Fortran (GCC) 4.5.3 - macosx
GNU Fortran (Ubuntu 4.4.3-4ubuntu5) 4.4.3

To trigger the bug, simply do

  gfortran bug.f90

Optimization level and other options do not seem to matter (but I have not
tried all). Note that many of the strange details in bug.f90 are necessary to
trigger the bug. For example, one of the indices of data must be a range while
the other must be a number. The => null() part is also necessary. And the array
must have at least two dimensions.

The different compilers involved where configured differently and built on
different systems, so I do not think the configuration matters much. But here
is the configuration from 4.7.0 20110811:

 sigurdkn@kaguya:~/code$ ~/local/gcc-build-debug/gcc/gfortran -v
 Using built-in specs.
 COLLECT_GCC=/home/sigurdkn/local/gcc-build-debug/gcc/gfortran
 Target: x86_64-unknown-linux-gnu
 Configured with: /home/sigurdkn/local/gcc-svn/configure
--prefix=/home/sigurdkn /local --program-suffix=-dbg
--enable-stage1-languages=c,fortran,c++
 Thread model: posix
 gcc version 4.7.0 20110811 (experimental) (GCC) 

Here is a stack trace from 4.7.0 20110811:

#0  *__GI___libc_free (mem=0x61) at malloc.c:3709
#1  0x00000000004bb5f5 in free_expr0 (e=0x1adca70)
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/expr.c:479
#2  0x00000000004bb6d2 in gfc_free_expr (e=0x1adca70)
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/expr.c:497
#3  0x0000000000544f42 in gfc_free_statement (p=0x1adc9a0)
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/st.c:84
#4  0x000000000054515c in gfc_free_statements (p=0x1adc9a0)
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/st.c:233
#5  0x000000000054c238 in gfc_free_namespace (ns=0x1ad8d30)
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/symbol.c:3246
#6  0x000000000054c3d2 in gfc_symbol_done_2 ()
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/symbol.c:3291
#7  0x00000000004f9347 in gfc_done_2 ()
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/misc.c:266
#8  0x000000000050f951 in translate_all_program_units
(gfc_global_ns_list=0x1ad8d30, 
    main_in_tu=1 '\001') at
/home/sigurdkn/local/gcc-svn/gcc/fortran/parse.c:4334
#9  0x000000000050fecc in gfc_parse_file ()
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/parse.c:4528
#10 0x0000000000555245 in gfc_be_parse_file ()
    at /home/sigurdkn/local/gcc-svn/gcc/fortran/f95-lang.c:250
#11 0x0000000000b36e7e in compile_file ()
    at /home/sigurdkn/local/gcc-svn/gcc/toplev.c:548
#12 0x0000000000b39107 in do_compile () at
/home/sigurdkn/local/gcc-svn/gcc/toplev.c:1886
#13 0x0000000000b39277 in toplev_main (argc=2, argv=0x7fffffffe578)
    at /home/sigurdkn/local/gcc-svn/gcc/toplev.c:1962
#14 0x00000000006099a0 in main (argc=2, argv=0x7fffffffe578)
    at /home/sigurdkn/local/gcc-svn/gcc/main.c:36

Reply via email to