https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118285
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The extra VAR_DECLs whose addresses are recorded in the initializers are
created in
#0 make_node (code=VAR_DECL) at ../../gcc/tree.cc:1244
#1 0x0000000001609ce1 in build_decl (loc=4611686018427387913, code=VAR_DECL,
name=<tree 0x0>, type=<record_type 0x7fffea2f37e0 A>) at ../../gcc/tree.cc:5421
#2 0x0000000000860eaf in build_local_temp (type=<record_type 0x7fffea2f37e0
A>) at ../../gcc/cp/tree.cc:562
#3 0x00000000008613e5 in build_aggr_init_expr (type=<record_type
0x7fffea2f37e0 A>, init=<call_expr 0x7fffea2f8500>) at ../../gcc/cp/tree.cc:672
#4 0x0000000000861a09 in build_cplus_new (type=<record_type 0x7fffea2f37e0 A>,
init=<call_expr 0x7fffea2f8500>, complain=3) at ../../gcc/cp/tree.cc:724
#5 0x000000000042d0fb in convert_like_internal (convs=0x43c0f40,
expr=<call_expr 0x7fffea2f8500>, fn=<tree 0x0>, argnum=0,
issue_conversion_warnings=true, c_cast_p=false,
nested_p=false, complain=3) at ../../gcc/cp/call.cc:8764
#6 0x000000000042f91c in convert_like (convs=0x43c0f40, expr=<array_ref
0x7fffea301bd0>, fn=<tree 0x0>, argnum=0, issue_conversion_warnings=true,
c_cast_p=false, nested_p=false,
complain=3) at ../../gcc/cp/call.cc:9322
#7 0x000000000042f98d in convert_like (convs=0x43c0f40, expr=<array_ref
0x7fffea301bd0>, complain=3) at ../../gcc/cp/call.cc:9335
#8 0x0000000000442b05 in perform_implicit_conversion_flags (type=<record_type
0x7fffea2f37e0 A>, expr=<array_ref 0x7fffea301bd0>, complain=3, flags=133)
at ../../gcc/cp/call.cc:13927
#9 0x000000000049d18c in cxx_eval_vec_init_1 (ctx=0x7fffffffab20,
atype=<array_type 0x7fffea2fa0a8>, init=<target_expr 0x7fffea2e4b60>,
value_init=false, lval=vc_prvalue,
non_constant_p=0x7fffffffd26f, overflow_p=0x7fffffffd26e) at
../../gcc/cp/constexpr.cc:5638
#10 0x000000000049d8ed in cxx_eval_vec_init (ctx=0x7fffffffab20,
t=<vec_init_expr 0x7fffea2f1208>, lval=vc_prvalue,
non_constant_p=0x7fffffffd26f, overflow_p=0x7fffffffd26e)
at ../../gcc/cp/constexpr.cc:5726
#11 0x00000000004a82c9 in cxx_eval_constant_expression (ctx=0x7fffffffab20,
t=<vec_init_expr 0x7fffea2f1208>, lval=vc_prvalue,
non_constant_p=0x7fffffffd26f,
overflow_p=0x7fffffffd26e, jump_target=0x0) at
../../gcc/cp/constexpr.cc:8215
now on
namespace std {
template <typename T> struct initializer_list {
T *_M_array;
__SIZE_TYPE__ _M_len;
};
}
struct A {
char *a;
union { char b[8]; long c; };
constexpr A (const char *x) : a(b)
{
for (int i = 0; i < 8; ++i)
b[i] = i + x[0];
}
constexpr ~A ()
{
if (!foo ())
bar (c);
}
constexpr bool foo ()
{
char *x = a;
if (x == b)
return true;
return false;
}
constexpr void bar (long) {}
};
constexpr void
baz (std::initializer_list<A>)
{
}
constexpr bool
qux ()
{
baz ({"1", "2"});
return true;
}
constexpr bool a = qux ();
So, instead of constructing it right into the A array it goes through some
temporary.