From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14181 invoked by alias); 4 May 2013 14:34:44 -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 14114 invoked by uid 48); 4 May 2013 14:34:41 -0000 From: "amodra at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/28865] Structures with a flexible arrray member have wrong .size Date: Sat, 04 May 2013 14:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: amodra at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.4 X-Bugzilla-Changed-Fields: 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 X-SW-Source: 2013-05/txt/msg00274.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28865 --- Comment #9 from Alan Modra 2013-05-04 14:34:39 UTC --- >>From what I see on current mainline for a testcase based on glibc/nss/nss_files/files-init.c the var_decl size and the type size agree and are correct. What causes a problem with -fsection-anchors is that the actual data emitted by output_constant() is wrong. struct traced_file { long pad; char fname[]; }; #define TF(id, filename, ...) \ union \ { \ struct traced_file file; \ char buf[sizeof (struct traced_file) + sizeof (filename)]; \ } id##_traced_file = \ { \ .file = \ { \ .fname = filename \ } \ } TF (pwd, "/etc/passwd"); TF (grp, "/etc/group"); Gives me .file "unioninit.c" .globl grp_traced_file .globl pwd_traced_file .section ".data" .align 2 .LANCB0: .org .LANCB0+0 .type grp_traced_file, @object .size grp_traced_file, 16 grp_traced_file: .zero 4 .string "/etc/group" .zero 12 .org .LANCB0+16 .type pwd_traced_file, @object .size pwd_traced_file, 16 pwd_traced_file: .zero 4 .string "/etc/passwd" .zero 12 .ident "GCC: (GNU) 4.9.0 20130502 (experimental)" .section .note.GNU-stack,"",@progbits Those ".zero 12" lines shouldn't be there.