From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6340 invoked by alias); 17 Apr 2015 13:03:37 -0000 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 Received: (qmail 6035 invoked by uid 48); 17 Apr 2015 13:03:29 -0000 From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/65673] Compound literal with initializer for zero-sized array drops other initializers Date: Fri, 17 Apr 2015 13:03: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-Version: 4.9.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek 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-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg01442.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65673 --- Comment #2 from Marek Polacek --- What happens here is that pop_init_level returns error_mark_node because initializing a zero-length array member with {} is discarded: 7565 /* Silently discard empty initializations. The parser will 7566 already have pedwarned for empty brackets. */ 7567 if (integer_zerop (constructor_unfilled_index)) 7568 constructor_type = NULL_TREE; thus ret.value is NULL: 7718 if (ret.value == 0 && constructor_stack == 0) 7719 ret.value = error_mark_node; 7720 return ret; output_init_element then sees that value == error_mark_node, so it marks the ctor as erroneous: 8388 if (type == error_mark_node || value == error_mark_node) 8389 { 8390 constructor_erroneous = 1; 8391 return; 8392 } And because the ctor is erroneous, we don't build a CONSTRUCTOR for it: 7668 if (constructor_erroneous) 7669 ret.value = error_mark_node; 7670 else 7671 { 7672 ret.value = build_constructor (constructor_type, 7673 constructor_elements);