From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11904 invoked by alias); 18 Nov 2005 05:53:55 -0000 Received: (qmail 11888 invoked by uid 48); 18 Nov 2005 05:53:52 -0000 Date: Fri, 18 Nov 2005 05:53:00 -0000 Subject: [Bug c/24931] New: uninitialized structure member after assignment X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dylan at dylex dot net" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2005-11/txt/msg02553.txt.bz2 List-Id: Consider this code: struct p { short x, y; }; struct s { int i; struct p p; }; struct s f() { struct s s; s.p = (struct p){}; s.i = (s.p.x || s.p.y); return s; } When compiled with gcc -Wall -O -c, it reports: t.c: In function 'f': t.c:14: warning: 's.i' is used uninitialized in this function That's not right. Furthermore, I think the generated assembly might be wrong (this is with -O): f: movl $0, %eax ret The return value should be a full 64 bits (%rax), but only the bottom 32 are initialized (unless this clears the high ones on x86_64 or the calling convention says they are already -- I don't really know). -- Summary: uninitialized structure member after assignment Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dylan at dylex dot net GCC build triplet: x86_64-pc-linux-gnu GCC host triplet: x86_64-pc-linux-gnu GCC target triplet: x86_64-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24931