From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ABBB63857C48; Tue, 7 Mar 2023 15:13:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABBB63857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678201996; bh=VNKsMm19htvlQcOxqHhzLIgTEcaOtx7VCNapYKO0tr0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FbYO4dwfKHo2WszNd3zyukX+rb00xb8Uc25F6wH6UCceWnutF3wEblT2MRLDlWE32 OD2Paf0I5xLepuA+cmgxTxqv/aAR3boidum8oDGPBc/2qnPjBDLR6H5SXLKJ7AFhiK pWzwZbBeVJ4ONkL4LP4otCuR+B/CR/dSK1TJk8Pc= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107939] [11/12/13 Regression] Rejects use of `extern const` variable in a template since r11-557 Date: Tue, 07 Mar 2023 15:13:15 +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: 13.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107939 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:e09bc034d1b4d692b409fa5af52ae34480a6f4dc commit r13-6525-ge09bc034d1b4d692b409fa5af52ae34480a6f4dc Author: Marek Polacek Date: Fri Mar 3 11:24:24 2023 -0500 c++: error with constexpr operator() [PR107939] Similarly to PR107938, this also started with r11-557, whereby cp_finish_decl can call check_initializer even in a template for a constexpr initializ= er. Here we are rejecting extern const Q q; template constexpr auto p =3D q(0); even though q has a constexpr operator(). It's deemed non-const by decl_maybe_constant_var_p because even though 'q' is const it is not of integral/enum type. If fun is not a function pointer, we don't know if we're using it as an lvalue or rvalue, so with this patch we pass 'any' for want_rval. With that, p_c_e/VAR_DECL doesn't flat out reject the underlying VAR_DECL. PR c++/107939 gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1) : Pass 'any' when recursing on a VAR_DECL and not a pointer to functio= n. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ74.C: Remove dg-error. * g++.dg/cpp1y/var-templ77.C: New test.=