From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E30E43858412; Mon, 25 Oct 2021 17:44:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E30E43858412 From: "wjwray at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55227] designated initializer for char array by string constant Date: Mon, 25 Oct 2021 17:44:10 +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: 4.8.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: wjwray 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2021 17:44:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55227 --- Comment #10 from Will Wray --- Note that the initialization of 'c0' takes a different codepath: struct C {char a[2];}; C c0{.a=3D"a"}; // [dcl.init.aggr] C c1{.a=3D""}; C c2{.a=3D{"a"}}; C c3{.a=3D{""}}; c1, c2 and c3 are all dealt with under the condition: if (TREE_CODE (type) =3D=3D ARRAY_TYPE ... c0 is dealt with by the immediately preceding [dcl.init.aggr] condition: if ((TREE_CODE (init) !=3D CONSTRUCTOR || COMPOUND_LITERAL_P (init)) ... Is this a problem? It seems surprising. If the two condition blocks were switched so the ARRAY_TYPE check comes fir= st then all initializations would follow the same codepath in reshape_init_r=