This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/69281] New: gfortran ICE on temporary array in function call with -fstack-arrays -fopenmp


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69281

            Bug ID: 69281
           Summary: gfortran ICE on temporary array in function call with
                    -fstack-arrays -fopenmp
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thomas.orgis@uni-hamburg.de
  Target Milestone: ---
              Host: x86_64-unknown-linux-gnu

Created attachment 37343
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37343&action=edit
example code triggering the ICE

Hi, here I am again crashing the GNU Fortran compiler. The attached code gives
an ICE with gfortran from 4.8.3 to 5.3.0 (maybe earlier, too) when activating
OpenMP and stack arrays:

$ gfortran -fstack-arrays -fopenmp  -c -o
test/notest_gfortran_ice_omp_add_variable.o
.preprocessed/test/notest_gfortran_ice_omp_add_variable.f90
.preprocessed/test/notest_gfortran_ice_omp_add_variable.f90:20:0:

    call midx_new(midx_counts2ranges(samples))
 ^
internal compiler error: in omp_add_variable, at gimplify.c:5644
0x8dd236 omp_add_variable
        ../../../src/gcc-5.3.0/gcc/gimplify.c:5642
0x8e3de8 gimplify_bind_expr
        ../../../src/gcc-5.3.0/gcc/gimplify.c:1108
0x8e22e9 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:8297
0x8e3816 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:5519
0x8e30d3 gimplify_and_add(tree_node*, gimple_statement_base**)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:423
0x8e30d3 gimplify_and_return_first
        ../../../src/gcc-5.3.0/gcc/gimplify.c:435
0x8e30d3 gimplify_omp_parallel
        ../../../src/gcc-5.3.0/gcc/gimplify.c:6901
0x8e30d3 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:8547
0x8e3816 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:5519
0x8e1d3b gimplify_statement_list
        ../../../src/gcc-5.3.0/gcc/gimplify.c:1487
0x8e1d3b gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:8515
0x8e3816 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:5519
0x8e401d gimplify_bind_expr
        ../../../src/gcc-5.3.0/gcc/gimplify.c:1136
0x8e22e9 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:8297
0x8e3816 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:5519
0x8e46c1 gimplify_body(tree_node*, bool)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:9234
0x8e49e7 gimplify_function_tree(tree_node*)
        ../../../src/gcc-5.3.0/gcc/gimplify.c:9388
0xaf7cf2 gimplify_all_functions
        ../../../src/gcc-5.3.0/gcc/tree-nested.c:3021
0xaf7cd7 gimplify_all_functions
        ../../../src/gcc-5.3.0/gcc/tree-nested.c:3023
0xaf9242 lower_nested_functions(tree_node*)
        ../../../src/gcc-5.3.0/gcc/tree-nested.c:3040
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


Removing either of -fopenmp or -fstack-arrays prevents the issue,
as does programming around the temporary storage created for the
function call. I hope that is specific enough to point out the
code to blame.

Fun fact: I stumbled upon this after experiencing the ridiculously
small OpenMP stack size of the Intel compiler despite unlimited
stack via ulimit. Because of the random crashes caused by this, they
may switch to defaulting to heap arrays like gfortran does. But since
Fortran is about efficient numerics, if anything, I very much prefer
temporary arrays to be on the stack as I am used to from other
compilers. Calling out malloc() for 10 bytes of local storage in a
function is not funny.

Since I figured out now why my code did not work with -fstack-arrays,
I may investigate what limit gfortran has for OpenMP stacks â

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]