https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102921
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2021-10-25 CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Testcase without headers: namespace std { typedef decltype (sizeof 0) size_t; template<class T> class initializer_list { const T *_M_array; size_t _M_len; constexpr initializer_list (const T &a, size_t l) : _M_array(a), _M_len(l) { } }; } struct S { constexpr S () noexcept { } int a = __builtin_is_constant_evaluated (); }; constexpr std::initializer_list <S> a { { } }; The <temporary> is _ZGRL1a_[0] demangled reference temporary #0 for a, and the expression that is being constant evaluated is (without cleanup points and expr_stmt): TARGET_EXPR <D.2197, {._M_array= (_ZGRL1a_[0] = TARGET_EXPR <D.2186, S::S (&D.2186)>;, (const struct S *) &_ZGRL1a_;, ._M_len=1}>; No idea how to fix that though... Doesn't seem to be a regression, behaved this way since r9-2311-ge408261123697a82b5965c700fa2465999f0fd62 when __builtin_is_constant_evaluated has been introduced. Without the builtin, bet the ctor is folded into a CONSTRUCTOR already when performing non-manifestly constant evaluation before. The INIT_EXPR that stores into _ZGRL1a_[0] is created by split_nonconstant_init_1 called indirectly from set_up_extended_ref_temp, so at that point the initializer clearly didn't go through manifestly constant evaluation. Should that be done somewhere if set_up_extended_ref_temp is called for a constexpr variable?