From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F17F4385842A; Sat, 3 Dec 2022 18:22:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F17F4385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670091728; bh=sdNfY85mrvatvp4W8y8qOjxsyDihtVbENrmp6NP7a7s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HxDpd5iB3Zk3P0tR9CPKESjfX/MKWd2UX8Xn0ibqIoZwQh9hNLqbzZwNkuidIwMXm ttzAmqgEOA6oXl18jSVRvaSuF16zKbugtp/wQxnIn66LK9vkaPGc0fynvtzwCUYumA ZEW7q0XzC/x5g6Ep9n0/gHpEUjNGiyiGz8nwaud4= From: "hstong at ca dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102000] Defaulted consteval default constructor that performs no initialization is not rejected Date: Sat, 03 Dec 2022 18:22:08 +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: 12.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: hstong at ca dot ibm.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=3D102000 Hubert Tong changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hstong at ca dot ibm.com --- Comment #4 from Hubert Tong --- (In reply to Johel Ernesto Guerrero Pe=C3=B1a from comment #3) > https://bugs.llvm.org/show_bug.cgi?id=3D51560#c1 points out > > I'm not sure what you think the problem is here. The constructor isn't= getting called; see http://eel.is/c++draft/dcl.init.general#8 . > It seems to me that they are right and the example above is well-formed. That depends on what "the semantic constraints for default-initialization a= re checked" means. (In reply to Johel Ernesto Guerrero Pe=C3=B1a from comment #0) > ``` > An immediate invocation shall be a constant expression. -- > https://eel.is/c++draft/expr.const#13.sentence-3 >=20 > Lots of wording in between... >=20 > 2 A variable or temporary object o is constant-initialized if > (2.1) either it has an initializer or its default-initialization resu= lts > in some initialization being performed, and > -- https://eel.is/c++draft/expr.const#2 > 7 To default-initialize an object of type T means: > (7.3) Otherwise, no initialization is performed. > -- https://eel.is/c++draft/dcl.init.general#7 > ``` That wording would be relevant for a similar case involving `constinit`. He= re, the relevant wording is in 7.7 [expr.const] paragraph 12 (and the uninitial= ized `int` is fine with the current wording). The example needs to be changed to= use pointers: ``` struct A { consteval A() =3D default; private: int *m; }; struct B { consteval B() =3D default; private: int *m, *n =3D 0; }; void f() { A a; // GCC accepts this despite pointer with indeterminate value B b; // GCC rejects this } ``` So it seems GCC just doesn't do certain checking when the constructor is trivial.=