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

            Bug ID: 63241
           Summary: Internal error in gimplify_init_constructor when using
                    constexr and multidimensional arrays
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thibaut.lutz at googlemail dot com

I stumbled upon a weird regression bug. The test case below is working fine
with GCC 4.8 and 4.9.0 but triggers an internal error on 4.9.1. I haven't
tested 4.9.2.

Any of these modifications would remove the error:
- removing `constexpr` from the constructor at line 2
- using `0` instead of `i` in the second array element constructor at line 8
- using `const int i` instead of `int i` at line 6
- using a 1D array instead of a 2D array at line 7
So I believe the example below cannot be reduced further.

However somehow the combination of `constexpr` constructor and multidimensional
array is causing the compiler to crash.

Details:

* GCC version: 4.9.1 built with default config

* System: x86_64 GNU/Linux

* Command line: c++ -std=c++11 bug.cpp

* Minimal example:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
struct A {
  constexpr A(int){}
};

int main() {
  int i = 1;
  A array[2][2] =
    {{{0}, {i}},
     {{0}, {0}}};
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

* Output:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bug.cpp: In function ‘int main()’:
bug.cpp:9:16: internal compiler error: in gimplify_init_constructor, at
gimplify.c:4007
      {{0}, {0}}};
                ^
0x7f6213 gimplify_init_constructor
        ../.././gcc/gimplify.c:4007
0x7f6dee gimplify_modify_expr_rhs
        ../.././gcc/gimplify.c:4167
0x7f6ec4 gimplify_modify_expr
        ../.././gcc/gimplify.c:4486
0x7f7dda gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../.././gcc/gimplify.c:7627
0x7facd6 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../.././gcc/gimplify.c:5373
0x7f806a gimplify_cleanup_point_expr
        ../.././gcc/gimplify.c:5149
0x7f806a gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../.././gcc/gimplify.c:7990
0x7facd6 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../.././gcc/gimplify.c:5373
0x7f8d3b gimplify_statement_list
        ../.././gcc/gimplify.c:1432
0x7f8d3b gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../.././gcc/gimplify.c:8042
0x7facd6 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../.././gcc/gimplify.c:5373
0x7f806a gimplify_cleanup_point_expr
        ../.././gcc/gimplify.c:5149
0x7f806a gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../.././gcc/gimplify.c:7990
0x7facd6 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../.././gcc/gimplify.c:5373
0x7f8d3b gimplify_statement_list
        ../.././gcc/gimplify.c:1432
0x7f8d3b gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../.././gcc/gimplify.c:8042
0x7facd6 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../.././gcc/gimplify.c:5373
0x7fb56b gimplify_bind_expr
        ../.././gcc/gimplify.c:1099
0x7f7fc0 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
        ../.././gcc/gimplify.c:7824
0x7facd6 gimplify_stmt(tree_node**, gimple_statement_base**)
        ../.././gcc/gimplify.c:5373
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.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Reply via email to