public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24931]  New: uninitialized structure member after assignment
@ 2005-11-18  5:53 dylan at dylex dot net
  2005-11-18  6:19 ` [Bug tree-optimization/24931] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dylan at dylex dot net @ 2005-11-18  5:53 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-02-03 16:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-18  5:53 [Bug c/24931] New: uninitialized structure member after assignment dylan at dylex dot net
2005-11-18  6:19 ` [Bug tree-optimization/24931] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-11-19  2:21 ` mmitchel at gcc dot gnu dot org
2005-11-20 20:08 ` rth at gcc dot gnu dot org
2005-11-21  0:51 ` [Bug tree-optimization/24931] [4.0/4.1/4.2 " rth at gcc dot gnu dot org
2005-11-21  0:56 ` rth at gcc dot gnu dot org
2005-11-22  0:06 ` [Bug tree-optimization/24931] [4.0 " pinskia at gcc dot gnu dot org
2006-03-11  3:19 ` mmitchel at gcc dot gnu dot org
2007-02-03 16:02 ` gdr at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).