This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/18501] [4.6/4.7/4.8 Regression] Missing 'used uninitialized' warning (CCP)
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Oct 2012 22:16:09 +0000
- Subject: [Bug tree-optimization/18501] [4.6/4.7/4.8 Regression] Missing 'used uninitialized' warning (CCP)
- Auto-submitted: auto-generated
- References: <bug-18501-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501
--- Comment #57 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-10-24 22:16:09 UTC ---
BTW, Clang has decided to implement this in the FE for simple cases.
Quoting: http://clang.llvm.org/docs/ReleaseNotes.html
-Wuninitialized has been taught to recognise uninitialized uses which always
occur when an explicitly-written non-constant condition is either true or
false. For example:
int f(bool b) {
int n;
if (b)
n = 1;
return n;
}
sometimes-uninit.cpp:3:7: warning: variable 'n' is used uninitialized whenever
'if' condition is false [-Wsometimes-uninitialized]
if (b)
^
sometimes-uninit.cpp:5:10: note: uninitialized use occurs here
return n;
^
sometimes-uninit.cpp:3:3: note: remove the 'if' if its condition is always true
if (b)
^~~~~~
sometimes-uninit.cpp:2:8: note: initialize the variable 'n' to silence this
warning
int n;
^
= 0