This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/71459] New: ICE writing to a string-initialized local array in a constexpr function
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Jun 2016 17:02:38 +0000
- Subject: [Bug c++/71459] New: ICE writing to a string-initialized local array in a constexpr function
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71459
Bug ID: 71459
Summary: ICE writing to a string-initialized local array in a
constexpr function
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
All versions of GCC that support C++ 14 constexpr functions fail with an ICE on
the following valid test case.
$ cat cst.C && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B
/home/msebor/build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -xc++ cst.C
constexpr int f ()
{
char a [] = "ab";
a [1] = 'c';
return 0;
}
constexpr int i = f ();
cst.C: In function âconstexpr int f()â:
cst.C:3:8: warning: variable âaâ set but not used [-Wunused-but-set-variable]
char a [] = "ab";
^
cst.C: At global scope:
cst.C:8:21: in constexpr expansion of âf()â
cst.C:8:22: internal compiler error: tree check: expected constructor, have
string_cst in cxx_eval_store_expression, at cp/constexpr.c:3072
constexpr int i = f ();
^
0x140cc34 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
/src/gcc-svn/gcc/tree.c:9752
0x792c15 tree_check(tree_node*, char const*, int, char const*, tree_code)
/src/gcc-svn/gcc/tree.h:3030
0xa6f784 cxx_eval_store_expression
/src/gcc-svn/gcc/cp/constexpr.c:3072
0xa71ccc cxx_eval_constant_expression
/src/gcc-svn/gcc/cp/constexpr.c:3656
0xa727df cxx_eval_constant_expression
/src/gcc-svn/gcc/cp/constexpr.c:3927
0xa71f2e cxx_eval_constant_expression
/src/gcc-svn/gcc/cp/constexpr.c:3697
0xa71f2e cxx_eval_constant_expression
/src/gcc-svn/gcc/cp/constexpr.c:3697
0xa7073a cxx_eval_statement_list
/src/gcc-svn/gcc/cp/constexpr.c:3352
0xa72e5e cxx_eval_constant_expression
/src/gcc-svn/gcc/cp/constexpr.c:3983
0xa72edd cxx_eval_constant_expression
/src/gcc-svn/gcc/cp/constexpr.c:3989
0xa6957c cxx_eval_call_expression
/src/gcc-svn/gcc/cp/constexpr.c:1500
0xa714db cxx_eval_constant_expression
/src/gcc-svn/gcc/cp/constexpr.c:3579
0xa737ca cxx_eval_outermost_constant_expr
/src/gcc-svn/gcc/cp/constexpr.c:4157
0xa73e63 cxx_constant_value(tree_node*, tree_node*)
/src/gcc-svn/gcc/cp/constexpr.c:4255
0x88c6e8 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
/src/gcc-svn/gcc/cp/typeck2.c:816
0x7d80de check_initializer
/src/gcc-svn/gcc/cp/decl.c:6172
0x7db1f2 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
/src/gcc-svn/gcc/cp/decl.c:6827
0x915ea7 cp_parser_init_declarator
/src/gcc-svn/gcc/cp/parser.c:18697
0x90b184 cp_parser_simple_declaration
/src/gcc-svn/gcc/cp/parser.c:12378
0x90af45 cp_parser_block_declaration
/src/gcc-svn/gcc/cp/parser.c:12246
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.