Bug 70489 - ICE in cxx_eval_increment_expression initializing a VLA in a constexpr function
Summary: ICE in cxx_eval_increment_expression initializing a VLA in a constexpr function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: C++VLA constexpr
  Show dependency treegraph
 
Reported: 2016-03-31 21:37 UTC by Martin Sebor
Modified: 2020-11-17 19:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 5.3.0, 6.0
Last reconfirmed: 2016-04-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2016-03-31 21:37:46 UTC
Current top of trunk (6.0) as well as 5.x both fail with an ICE on the following valid code.

$ cat t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -Wall -xc++ t.c
constexpr int f (int m, int n)
{
    char a [m][n] = { 1, 2, 3, 4 };
    return 0;
}

constexpr int i = f (2, 2);
t.c: In function ‘constexpr int f(int, int)’:
t.c:3:10: warning: unused variable ‘a’ [-Wunused-variable]
     char a [m][n] = { 1, 2, 3, 4 };
          ^
t.c: At global scope:
t.c:7:21:   in constexpr expansion of ‘f(2, 2)’
t.c:7:26: internal compiler error: in cxx_eval_increment_expression, at cp/constexpr.c:3001
 constexpr int i = f (2, 2);
                          ^
0x106f3147 cxx_eval_increment_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3001
0x106f6daf cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3789
0x106f63eb cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3720
0x106f5b47 cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3492
0x106f3a7f cxx_eval_statement_list
	/src/gcc/trunk/gcc/cp/constexpr.c:3152
0x106f6cff cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3776
0x106f63eb cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3720
0x106f63eb cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3720
0x106f5b47 cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3492
0x106f5b47 cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3492
0x106f3a7f cxx_eval_statement_list
	/src/gcc/trunk/gcc/cp/constexpr.c:3152
0x106f6cff cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3776
0x106f6d83 cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3782
0x106eb17b cxx_eval_call_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:1393
0x106f502b cxx_eval_constant_expression
	/src/gcc/trunk/gcc/cp/constexpr.c:3374
0x106f77fb cxx_eval_outermost_constant_expr
	/src/gcc/trunk/gcc/cp/constexpr.c:3939
0x106f80af cxx_constant_value(tree_node*, tree_node*)
	/src/gcc/trunk/gcc/cp/constexpr.c:4028
0x1046900b store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
	/src/gcc/trunk/gcc/cp/typeck2.c:822
0x1037bc43 check_initializer
	/src/gcc/trunk/gcc/cp/decl.c:6155
0x1037f797 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
	/src/gcc/trunk/gcc/cp/decl.c:6783
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 Marek Polacek 2016-04-01 15:12:32 UTC
Confirmed.
Comment 2 Marek Polacek 2020-11-17 19:02:32 UTC
Fixed by r276563 in GCC 10.