User account creation filtered due to spam.

Bug 21357 - Erroneous warning: " ... may be used uninitialized in this function"
Summary: Erroneous warning: " ... may be used uninitialized in this function"
Status: RESOLVED DUPLICATE of bug 5035
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 21358 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-05-03 13:07 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:07:22 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:12 UTC
*** Bug 21358 has been marked as a duplicate of this bug. ***
Comment 2 Andrew Pinski 2005-05-03 13:43:43 UTC
This is known and a long standing bug.
Comment 3 Joseph S. Myers 2005-05-03 20:20:32 UTC
Not a C front end bug and previously reported more than once.


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