User account creation filtered due to spam.

Bug 37148 - -Wunintialized fails in the face of conditional initialization.
Summary: -Wunintialized fails in the face of conditional initialization.
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-18 13:31 UTC by thutt
Modified: 2008-08-18 13:46 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description thutt 2008-08-18 13:31:34 UTC
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.
Comment 1 Manuel López-Ibáñez 2008-08-18 13:46:02 UTC
CCP removes the uninitialized use.

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