https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110999
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` storage definition. But it rejects it if the method definition is inline in the class. ``` struct OutOfLine { static const OutOfLine kConstant; constexpr int f(); int i = 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 = 2; }; inline constexpr InLine InLine::kConstant; int main() { constexpr int x = OutOfLine().f(); constexpr int y = InLine().f(); } ```