Bug 51740 - warning "is used uninitialized in this function" is missing if the variable initialized later
Summary: warning "is used uninitialized in this function" is missing if the variable i...
Status: CLOSED DUPLICATE of bug 50040
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-03 14:28 UTC by Szókovács Róbert
Modified: 2012-01-03 19:26 UTC (History)
0 users

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


Attachments
Code that should warn (118 bytes, text/x-csrc)
2012-01-03 14:28 UTC, Szókovács Róbert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Szókovács Róbert 2012-01-03 14:28:21 UTC
Created attachment 26231 [details]
Code that should warn

gcc fails to emit the "is used uninitialized in this function" warning, if the offending variable is initialized via a function later on.

See attachment. If compiled with 
gcc  -Wall  bug.c
gcc issues no warning. If line 13 is commented out, the correct
bug.c:11:9: warning: ‘offender’ is used uninitialized in this function [-Wuninitialized]
is emitted.
I think it's not the same as #18501, because replacing line 13 with
offencer = 0;
still produces the warning correctly.
Comment 1 Richard Biener 2012-01-03 15:16:57 UTC
This is a dup of PR50040, fixed for GCC 4.7.  Note that you need to enable
optimization to get the warning there.

*** This bug has been marked as a duplicate of bug 50040 ***
Comment 2 Szókovács Róbert 2012-01-03 19:26:18 UTC
confirmed it's fixed in 4.7