public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111301] New: misleading messages about missing "inline"
@ 2023-09-06 3:52 f.heckenbach@fh-soft.de
2023-09-06 4:05 ` [Bug c++/111301] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: f.heckenbach@fh-soft.de @ 2023-09-06 3:52 UTC (permalink / raw)
To: gcc-bugs
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.heckenbach@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).
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/111301] misleading messages about missing "inline"
2023-09-06 3:52 [Bug c++/111301] New: misleading messages about missing "inline" f.heckenbach@fh-soft.de
@ 2023-09-06 4:05 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-06 4:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111301
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the float case is actually supposed to be rejected without a const for the
same reason as the int ...
GCC had an extension which allowed `const static float` being initialized
`in-class initialization` which was removed (well rather allowed only with
-fpermissive ) in GCC 4.7. Looks like the change which removed the extension
changed how non-const static initialized for non-const errors out ...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-06 4:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-06 3:52 [Bug c++/111301] New: misleading messages about missing "inline" f.heckenbach@fh-soft.de
2023-09-06 4:05 ` [Bug c++/111301] " pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).