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

Reply via email to