Bug 63241 - Internal error in gimplify_init_constructor when using constexr and multidimensional arrays
Summary: Internal error in gimplify_init_constructor when using constexr and multidime...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.1
: P3 normal
Target Milestone: 4.9.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-12 12:36 UTC by Thibaut LUTZ
Modified: 2014-09-17 14:31 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thibaut LUTZ 2014-09-12 12:36:35 UTC
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.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Comment 1 Paolo Carlini 2014-09-17 14:12:18 UTC
This is already fixed in current 4_9-branch. I'm adding the testcase and closing the bug.
Comment 2 paolo@gcc.gnu.org 2014-09-17 14:30:50 UTC
Author: paolo
Date: Wed Sep 17 14:30:18 2014
New Revision: 215326

URL: https://gcc.gnu.org/viewcvs?rev=215326&root=gcc&view=rev
Log:
2014-09-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/63241
	* g++.dg/cpp0x/constexpr-63241.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-63241.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 3 paolo@gcc.gnu.org 2014-09-17 14:31:06 UTC
Author: paolo
Date: Wed Sep 17 14:30:35 2014
New Revision: 215327

URL: https://gcc.gnu.org/viewcvs?rev=215327&root=gcc&view=rev
Log:
2014-09-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/63241
	* g++.dg/cpp0x/constexpr-63241.C: New.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-63241.C
Modified:
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
Comment 4 Paolo Carlini 2014-09-17 14:31:43 UTC
Done.