From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3956E3858433; Mon, 25 Oct 2021 08:03:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3956E3858433 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102921] error: modification of '' is not a constant expression Date: Mon, 25 Oct 2021 08:03:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2021 08:03:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102921 Jakub Jelinek 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 --- Testcase without headers: namespace std { typedef decltype (sizeof 0) size_t; template 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 =3D __builtin_is_constant_evaluated (); }; constexpr std::initializer_list a { { } }; The 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 ;, (const struct S *) &_ZGRL1a_;, ._M_len=3D1}>; No idea how to fix that though... Doesn't seem to be a regression, behaved this way since=20 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, s= o 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?=