https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111301
Bug ID: 111301 Summary: misleading messages about missing "inline" Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.heckenb...@fh-soft.de Target Milestone: --- Another case of misleading messages: % cat test.cpp struct S { static int i = 0; static float f = 0; }; % g++ -c -std=c++23 test.cpp test.cpp:3:14: error: ISO C++ forbids in-class initialization of non-const static member 'S::i' 3 | static int i = 0; | ^ test.cpp:4:16: error: 'constexpr' needed for in-class initialization of static data member 'float S::f' of non-integral type [-fpermissive] 4 | static float f = 0; | ^ First of all, the two different messages are irritating. As I understand it, that's because there is an exception for "static const int", apparently mostly for historic reasons, and actually not really relevant here. Anyway, even if it seems worth mentioning this exception at all (I doubt it now that we have constexpr), the messages could be merged, saying "non-const, non-integral ..." to make it clearer it's actually the same issue both times. Also, "forbid" and "needed" is too strongly worded now that "static inline" is also possible (and in fact what I meant to write).