From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 870C53858D28; Wed, 6 Sep 2023 03:52:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 870C53858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693972338; bh=8nys+LNL2kqdOn+VC8WyZfroAUyfZ2mzF8GzrJXCf7Q=; h=From:To:Subject:Date:From; b=DWYEbC6Xipfq2gVrVXNu45aDQW6nWL5Zp0A9Tx+AYRL2J5xNq2J2/ixtGC9QiRaOK yXYwchXLplMlbTNOQObIZGS3A0lhGSRKlywNcq3QgTM08l9H/OpwNoZVmU4xeuH2U3 YDTC/yEwywwc799/n2bJwkn3ETxUzYMZU4CJ1B9k= From: "f.heckenbach@fh-soft.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111301] New: misleading messages about missing "inline" Date: Wed, 06 Sep 2023 03:52:18 +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: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: f.heckenbach@fh-soft.de 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=3D111301 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 =3D 0; static float f =3D 0; }; % g++ -c -std=3Dc++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 =3D 0; | ^ test.cpp:4:16: error: 'constexpr' needed for in-class initialization of sta= tic data member 'float S::f' of non-integral type [-fpermissive] 4 | static float f =3D 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 mos= tly for historic reasons, and actually not really relevant here. Anyway, even i= f 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).=