From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4F2D384F976; Wed, 14 Dec 2022 20:14:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4F2D384F976 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671048847; bh=3EiPgj2pOTWdGBqha/fyRvraMDTgs62FV0bryI8Nd9w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sijFlhUE2y7zb0w7aMIi2i4nUz2BldFennbIZL7coG3innNncyfy4fo81pmI4Qx28 jteiBUqqLm85dc3RErS0D3FoIsZab6oy9rlcurJDef+GthxAy9O3a9ydkj9IHhWHtd p/Sl1Q8mZdC0MyJt6y8Q6JM0jy7PQj7a9DnASKkI= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108114] Designated initialization of parent class results in error in C++20 mode Date: Wed, 14 Dec 2022 20:14:07 +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.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: 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=3D108114 --- Comment #1 from Andrew Pinski --- clang gives: :11:19: warning: mixture of designated and non-designated initializ= ers in the same initializer list is a C99 extension [-Wc99-designator] B b{{.a =3D 0}, .b =3D 1}; ^~~~~~ :11:9: note: first non-designated initializer is here B b{{.a =3D 0}, .b =3D 1}; ^~~~~~~~ With -std=3Dc++17 -pedantic GCC produces: : In function 'int main()': :11:10: warning: C++ designated initializers only available with '-std=3Dc++20' or '-std=3Dgnu++20' [-Wc++20-extensions] 11 | B b{{.a =3D 0}, .b =3D 1}; | ^ :11:19: warning: C++ designated initializers only available with '-std=3Dc++20' or '-std=3Dgnu++20' [-Wc++20-extensions] 11 | B b{{.a =3D 0}, .b =3D 1}; | ^ In GCC 7 (and before) -std=3Dc++17 -pedantic GCC gives: : In function 'int main()': :11:9: warning: ISO C++ does not allow C99 designated initializers [-Wpedantic] B b{{.a =3D 0}, .b =3D 1}; ^ :11:17: warning: ISO C++ does not allow C99 designated initializers [-Wpedantic] B b{{.a =3D 0}, .b =3D 1}; ^ Most likely just a difference between C99 and C++20 support. Also note "but this is not an error" is because if you use -pedantic-errors= you would get an error with clang and even GCC with -std=3Dc++17.=