https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94066
Bug ID: 94066
Summary: ICE (starting/ending union member lifetime) in
cxx_eval_bare_aggregate, at cp/constexpr.c:3790
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hstong at ca dot ibm.com
Target Milestone: ---
The following case, which (during constant expression evaluation) starts the
lifetime of a union member while evaluating a function whose return value would
become the other union member leads to an ICE.
### SOURCE (<stdin>):
struct A { long x; };
union U;
constexpr A foo(U *up);
union U {
A a = foo(this); int y;
};
constexpr A foo(U *up) {
up->y = 11;
return {42};
}
extern constexpr U u = {};
### COMPILER INVOCATION:
g++ -fsyntax-only -xc++ -std=c++2a -
### COMPILER OUTPUT:
<stdin>:15:25: internal compiler error: in cxx_eval_bare_aggregate, at
cp/constexpr.c:3790
0x5bac9e cxx_eval_bare_aggregate
../../source/gcc/cp/constexpr.c:3790
0x6305d4 cxx_eval_constant_expression
../../source/gcc/cp/constexpr.c:5853
0x632610 cxx_eval_outermost_constant_expr
../../source/gcc/cp/constexpr.c:6409
0x635c14 maybe_constant_init_1
../../source/gcc/cp/constexpr.c:6866
0x78167c store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
../../source/gcc/cp/typeck2.c:889
0x66480d check_initializer
../../source/gcc/cp/decl.c:6820
0x67863c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
../../source/gcc/cp/decl.c:7746
0x6fad51 cp_parser_init_declarator
../../source/gcc/cp/parser.c:20839
0x6ddc72 cp_parser_simple_declaration
../../source/gcc/cp/parser.c:13689
0x7030c2 cp_parser_declaration
../../source/gcc/cp/parser.c:13388
0x7037e4 cp_parser_translation_unit
../../source/gcc/cp/parser.c:4731
0x7037e4 c_parse_file()
../../source/gcc/cp/parser.c:43760
0x7cb39b c_common_parse_file()
../../source/gcc/c-family/c-opts.c:1186
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.0.1 20200304 (experimental) (GCC)