This testcase causes GNU Fortran versions shown below (as far as I know): 4.2.1 4.3.0 to crash with `internal compiler error'.
This testcase shows some "features" that must exist in order to cause the compiler to fail: - inside the OpenMP section, it accesses a module variable (ModuleVar) - the enclosing subroutine (named `crash' in the testcase) contains one or more nested subroutines/functions. If NO nested subroutine is defined inside the function, then all is OK. Some "invariants": - the !$omp master directive is optional; the crash occurs regardless whether it is present. - the access mode of ModuleVar does not matter--it can be a write or a read - the `subroutine' keyword can be replaced with `program', and it still crashes. Here's the gfortran output: $ gfortran -c -fopenmp crash.f95 crash.f95:39: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. $ /usr/local/gcc-4.3.0/libexec/gcc/i686-pc-linux-gnu/4.3.0/f951 -fopenmp crash.f95 crash blah crash.f95: At top level: crash.f95:39: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Here's the debugging output: $ gdb /usr/local/gcc-4.3.0/libexec/gcc/i686-pc-linux-gnu/4.3.0/f951 GNU gdb 6.6-debian Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i486-linux-gnu"... Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1". (gdb) run -fopenmp crash.f95 Starting program: /usr/local/gcc-4.3.0/libexec/gcc/i686-pc-linux-gnu/4.3.0/f951 -fopenmp crash.f95 crash blah Program received signal SIGSEGV, Segmentation fault. get_frame_type (info=0x0) at ../../gcc-4.3.0/gcc/tree-nested.c:198 198 tree type = info->frame_type; (gdb) where #0 get_frame_type (info=0x0) at ../../gcc-4.3.0/gcc/tree-nested.c:198 #1 0x082be86f in get_chain_decl (info=0x87ab180) at ../../gcc-4.3.0/gcc/tree-nested.c:304 #2 0x082bf872 in get_nonlocal_debug_decl (info=0x87ab180, decl=0xb7caa1b8) at ../../gcc-4.3.0/gcc/tree-nested.c:904 #3 0x082c11e4 in convert_nonlocal_omp_clauses (pclauses=<value optimized out>, wi=0xbfe1bfbc) at ../../gcc-4.3.0/gcc/tree-nested.c:1181 #4 0x082c0e99 in convert_nonlocal_reference (tp=0xb7ccd5fc, walk_subtrees=0xbfe1bec8, data=0xbfe1bfbc) at ../../gcc-4.3.0/gcc/tree-nested.c:1099 #5 0x08382e8d in walk_tree_1 (tp=0xb7ccd5fc, func=0x82c0c80 <convert_nonlocal_reference>, data=0xbfe1bfbc, pset=0x0, lh=0) at ../../gcc-4.3.0/gcc/tree.c:8391 #6 0x082bfd30 in walk_stmts (wi=0xbfe1bfbc, tp=0xb7ccd5fc) at ../../gcc-4.3.0/gcc/tree-nested.c:640 #7 0x082bfefd in walk_stmts (wi=0xbfe1bfbc, tp=0xb7cab0e8) at ../../gcc-4.3.0/gcc/tree-nested.c:575 #8 0x082bfd78 in walk_stmts (wi=0xbfe1bfbc, tp=0xb7cd7d08) at ../../gcc-4.3.0/gcc/tree-nested.c:594 #9 0x082bffab in walk_body (callback=0x82c0c80 <convert_nonlocal_reference>, info=0x0, stmt_p=0xb7caa1b8) at ../../gcc-4.3.0/gcc/tree-nested.c:657 #10 0x082bffed in walk_all_functions (callback=0x82c0c80 <convert_nonlocal_reference>, root=0x87ab180) at ../../gcc-4.3.0/gcc/tree-nested.c:665 #11 0x082c00ca in lower_nested_functions (fndecl=0xb7cd7cb0) at ../../gcc-4.3.0/gcc/tree-nested.c:2001 #12 0x083cec09 in cgraph_finalize_function (decl=0xb7cd7cb0, nested=0 '\0') at ../../gcc-4.3.0/gcc/cgraphunit.c:620 #13 0x080de9bf in gfc_generate_function_code (ns=0x87aaa38) at ../../gcc-4.3.0/gcc/fortran/trans-decl.c:3376 #14 0x0809bdad in gfc_parse_file () at ../../gcc-4.3.0/gcc/fortran/parse.c:3579 #15 0x080c71c5 in gfc_be_parse_file (set_yydebug=0) at ../../gcc-4.3.0/gcc/fortran/f95-lang.c:260 #16 0x0828ef04 in toplev_main (argc=3, argv=0xbfe1c334) at ../../gcc-4.3.0/gcc/toplev.c:1042 #17 0x0810145f in main (argc=150994976, argv=0x0) at ../../gcc-4.3.0/gcc/main.c:35 Note that I built my own GCC on an Intel Pentium M laptop with Ubuntu 7.04 Linux, and using gmp version 4.2.2 and mpfr 2.3.1 . -- Summary: OpenMP code segment with module variable causes Fortran compiler to crash Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wirawan0 at gmail dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36632