This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/18501] [4.6/4.7/4.8 Regression] Missing 'used uninitialized' warning (CCP)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]