[LLVMbugs] [Bug 19899] Warn user about comparision of reference to nullptr

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 6 15:28:10 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19899

rtrieu at google.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from rtrieu at google.com ---
Committed in r210372

$ cat PR19899.cc
bool foo(int &x) { return &x == 0; }
struct S { bool f() { return this == nullptr; } };

$ clang -fsyntax-only PR19899.cc -std=c++11
PR19899.cc:1:28: warning: reference cannot be bound to dereferenced null
pointer
      in well-defined C++ code; comparison may be assumed to always evaluate to
      false [-Wtautological-undefined-compare]
bool foo(int &x) { return &x == 0; }
                           ^    ~
PR19899.cc:2:30: warning: 'this' pointer cannot be null in well-defined C++
      code; comparison may be assumed to always evaluate to false
      [-Wtautological-undefined-compare]
struct S { bool f() { return this == nullptr; } };
                             ^~~~    ~~~~~~~
2 warnings generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140606/3e91cb52/attachment.html>


More information about the llvm-bugs mailing list