Bug 21358 - Erroneous warning: " ... may be used uninitialized in this function"
Summary: Erroneous warning: " ... may be used uninitialized in this function"
Status: RESOLVED DUPLICATE of bug 21357
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-03 13:10 UTC by William Gallafent
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
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 William Gallafent 2005-05-03 13:10:16 UTC
Output of gcc -v: 
 
Using built-in specs. 
Target: x86_64-unknown-linux-gnu 
Configured with: ../gcc-4.0.0/configure --prefix=/home/williamg/local/x86_64-40 
--enable-__cxa_atexit --enable-languages=c,c++ 
Thread model: posix 
gcc version 4.0.0 
 
Command line: 
~/local/x86_64-40/bin/gcc -O1 -Wall -Werror -c 3.c -o 3.o 
 
Output: 
cc1: warnings being treated as errors 
3.c: In function ‘main’: 
3.c:6: warning: ‘initialised_when_a_is_non_zero’ may be used uninitialized in 
this function 
 
Preprocessed source: 
 
# 1 "3.c" 
# 1 "<built-in>" 
# 1 "<command line>" 
# 1 "3.c" 
 
extern int g (int); 
 
int main () { 
 const int a = g (0); 
 int initialised_when_a_is_non_zero; 
 if (a) 
  initialised_when_a_is_non_zero = 10; 
 g (1); 
 if (a) 
  g (initialised_when_a_is_non_zero); 
 return 0; 
} 
 
It's clearly impossible that we use initialised_when_a_is_non_zero unless it 
has been initialised. 
 
The warning does not appear with -O0. 
 
Removing the line "g (1);" also makes the warning disappear.
Comment 1 William Gallafent 2005-05-03 13:32:03 UTC
Browser hung for 5 minutes after first submit without showing a "bug submitted" 
page, so I tried again ... apologies for noise. 

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