public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37148]  New: -Wunintialized fails in the face of conditional assignment.
@ 2008-08-18 13:32 thutt at vmware dot com
  2008-08-18 13:47 ` [Bug c/37148] -Wunintialized fails in the face of conditional initialization manu at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: thutt at vmware dot com @ 2008-08-18 13:32 UTC (permalink / raw)
  To: gcc-bugs

Although I demonstrated this using 4.1.2 on my host, it probably affects
other versions as well.

As the following code shows:

    gcc -c -O1 -Wall -Werror uninitialized-warning.c

    extern void called_function(unsigned p);
    extern unsigned g;

    void
    f0(unsigned parm)
    {
       unsigned v;
       if (parm == 0) {
          v = 4;
       }
       called_function(v);
    }

    void
    f1(unsigned parm)
    {
       unsigned v;
       if (parm == 0) {
          v = 4;
       } else {
          g = 0;
       }
       called_function(v);
    }

    void
    f2(unsigned parm)
    {
       unsigned v;
       called_function(v);
    }

gcc does not produce the 'uninitialized' warning when the automatic
variable is conditionally assigned.

This gives a very bad false sense of security that the automatic
variables are indeed initialized.


-- 
           Summary: -Wunintialized fails in the face of conditional
                    assignment.
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thutt at vmware dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37148


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

* [Bug c/37148] -Wunintialized fails in the face of conditional initialization.
  2008-08-18 13:32 [Bug c/37148] New: -Wunintialized fails in the face of conditional assignment thutt at vmware dot com
@ 2008-08-18 13:47 ` manu at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-08-18 13:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from manu at gcc dot gnu dot org  2008-08-18 13:46 -------
CCP removes the uninitialized use.

*** This bug has been marked as a duplicate of 18501 ***


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37148


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

end of thread, other threads:[~2008-08-18 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-18 13:32 [Bug c/37148] New: -Wunintialized fails in the face of conditional assignment thutt at vmware dot com
2008-08-18 13:47 ` [Bug c/37148] -Wunintialized fails in the face of conditional initialization manu 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).