From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1563 invoked by alias); 23 Jan 2013 14:23:48 -0000 Received: (qmail 1524 invoked by uid 48); 23 Jan 2013 14:23:30 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/56078] causes cc1 to crash Date: Wed, 23 Jan 2013 14:23:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg02171.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56078 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jsm28 at gcc dot gnu.org --- Comment #4 from Jakub Jelinek 2013-01-23 14:23:30 UTC --- Note, the code is not valid ISO C99, which forbids initialization of flexible array members, but a GNU extension, apparently not sufficiently well defined. E.g. in struct T t2 = { .a = 1, .b[0] = 'a' }; the .b[0] initializer is ignored with a warning, only initializing it as whole, whether as in #c3 without that extra ", .b[0] = '2'", or e.g. as in struct T t3 = { .a = 1, .b = { [0] = 'a', [1] = 'b', [2] = 'c' } }; So the question is how exactly we want to handle the flexible array members vs. designated initializers, if we take the size from the first initializer and all further ones will be either ignored (if beyond that size) or overwrite the initializer, or if we e.g. take the highest array index ever seen anywhere. So, say, is struct T t4 = { .a = 1, .b[5] = '5', .b[7] = '7' }; the same as struct T t4 = { .a = 1, .b = { 0, 0, 0, 0, 0, '5' }; with warning or: struct T t4 = { .a = 1, .b = { 0, 0, 0, 0, 0, '5', 0, '7' }; ?