From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 40FBD3858415; Sun, 23 Jan 2022 22:27:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40FBD3858415 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55227] designated initializer for char array by string constant Date: Sun, 23 Jan 2022 22:27:32 +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: patch, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org 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: Sun, 23 Jan 2022 22:27:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55227 --- Comment #16 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:2da90ad39bf8fa9ee287e040d1f4411cb7a2e7ed commit r12-6825-g2da90ad39bf8fa9ee287e040d1f4411cb7a2e7ed Author: Will Wray Date: Fri Jan 14 19:28:53 2022 -0500 c++: designated init of char array by string constant [PR55227] There are two underlying bugs in the designated initialization of char array fields by string literals that cause: (1) Rejection of valid cases with: (a) brace-enclosed string literal initializer (of any valid size), or (b) unbraced string literal shorter than the target char array field. (2) Acceptance of invalid cases with designators appearing within the braces of a braced string literal, in which case the bogus 'designator' was being entirely ignored and the string literal treated as a position= al initializer. The fixes above allow to address a FIXME in cp_complete_array_type: /* FIXME: this code is duplicated from reshape_init. Probably we should just call reshape_init here? */ I believe that this was obstructed by the designator bugs (see comment = here https://patchwork.ozlabs.org/project/gcc/list/?series=3D199783) PR c++/55227 gcc/cp/ChangeLog: * decl.cc (reshape_init_r): Only call has_designator_check when first_initializer_p or for the inner constructor element. (cp_complete_array_type): Call reshape_init on braced-init-list. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/desig21.C: New test.=