From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C3B653858D39; Wed, 3 Apr 2024 01:28:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3B653858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712107734; bh=qAtRfl001GLXnA7yAPD0ZDx3ZtUoBInKYN7JsTbJRdY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SWk2LjVWXcLaCfn3EcTOg5KTy6HARhGcqtDW1l91VTGwCmTZhqsKwrW+7J6jcffm5 8ceT5aNUGh7tWq3HCczNXL9naE0tvMdIg4bveUxUBUbdB9n+ddougSmfEaf9MvxCZs nZv5ki9qv2QQFxTGzPZVdLQH2knzJXo2nWqZ+hp0= From: "bbi5291 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107945] static constexpr incomplete (depedent) data member of a class template and in-member initialized incorrectly accepted Date: Wed, 03 Apr 2024 01:28:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: bbi5291 at gmail dot com X-Bugzilla-Status: NEW 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: cc Message-ID: In-Reply-To: References: 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=3D107945 Brian Bi changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bbi5291 at gmail dot com --- Comment #5 from Brian Bi --- In the first case, I think GCC's behaviour can be argued to be correct. [temp.inst]/3.1 says that when you implicitly instantiate a class template,= you only instantiate the declarations of static data members, not their definitions. Which means that until you do something that provokes the instantiation of the *definition* of `C::t`, the compiler must treat it as a variable of type `const incomplete` that is declared-but-not-defined, which means that you haven't yet actually attempt= ed to define a variable with incomplete type, which means the program is well-formed. In the most recent example given by Jason Liam we can reduce it to: template struct S { constexpr static S s =3D {}; }; int main() { auto s =3D S::s; } This may be related to bug 70820, which was closed as INVALID. I think perh= aps that decision should be revisited; while I can see the argument for the abo= ve code being well-formed, I think the interpretation of the standard being ta= ken in this case is wrong.=