[llvm-bugs] [Bug 13956] Clang doesn't emit tautological-compare warning when nonnull is compared against NULL

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 18 15:51:31 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=13956

Nick Lewycky <nlewycky at google.com> changed:

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

--- Comment #2 from Nick Lewycky <nlewycky at google.com> ---
Looking over old bugs, these appear to be fixed!

pr13956-1.cc:3:12: warning: comparison of nonnull parameter 'x' equal to a null
      pointer is 'false' on first encounter [-Wtautological-pointer-compare]
    return x == NULL;
           ^    ~~~~

pr13956-2.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; }
                           ^    ~

The idea of __attribute__((nonnull(x))) or 'void f(__attribute__((nonnull)) int
*x);' will have to live elsewhere.

-- 
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/20160518/00925ed3/attachment.html>


More information about the llvm-bugs mailing list