From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B6F433858C66; Sat, 12 Aug 2023 04:44:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6F433858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691815466; bh=nrS5dirU3uyos4JWm4XPa6IQ+GjtdosxTYA3liIQMMI=; h=From:To:Subject:Date:From; b=o9ZBPclDvZBGM8cp1F5U8fQDnXdkPL/pcV3hy+RU4zbEahj3UQQEA0Rw9LxUhG5wA vwAuD0dsItLWvQrnDOlwXQ1Xn/p6fZUgBCnWkxYb1m0NSRCWwf5LJubBjOkI78EFBa 9w50qxFzG5Aski6E85t4pMaJoFPC/fHm+VgTxNgY= From: "danakj at orodu dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110999] New: GCC rejects static variable with constexpr storage from inline method definition Date: Sat, 12 Aug 2023 04:44:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: danakj at orodu dot net X-Bugzilla-Status: UNCONFIRMED 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_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D110999 Bug ID: 110999 Summary: GCC rejects static variable with constexpr storage from inline method definition Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: danakj at orodu dot net Target Milestone: --- Godbolt: https://godbolt.org/z/srvhxjqqz GCC will accept it if the method definition comes after the `constexpr` sto= rage definition. But it rejects it if the method definition is inline in the cla= ss. ``` struct OutOfLine { static const OutOfLine kConstant; constexpr int f(); int i =3D 2; }; inline constexpr OutOfLine OutOfLine::kConstant; // Accepted. constexpr int OutOfLine::f() { return kConstant.i; } struct InLine { static const InLine kConstant; // Rejected. constexpr int f() { return kConstant.i; } int i =3D 2; }; inline constexpr InLine InLine::kConstant; int main() { constexpr int x =3D OutOfLine().f(); constexpr int y =3D InLine().f(); } ```=