[llvm-bugs] [Bug 34362] New: zero-as-null-pointer-constant warning on nullptr.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 29 11:43:44 PDT 2017


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

            Bug ID: 34362
           Summary: zero-as-null-pointer-constant warning on nullptr.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bungeman at gmail.com
                CC: llvm-bugs at lists.llvm.org

With the following content in zero.cc

struct A { operator int*() { return nullptr; } };
int main() { if (nullptr == A()) {} }


$ clang++ --version
clang version 6.0.0 (trunk 312002)

$ clang++ --std=c++11 -c zero.cc -Wzero-as-null-pointer-constant
zero.cc:2:18: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
int main() { if (nullptr == A()) {} }
                 ^~~~~~~
                 nullptr
1 warning generated.


It appears that the user-defined conversion is getting in the way of the
detection somehow. This appears to have been introduced by D32914.

-- 
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/20170829/c772f371/attachment.html>


More information about the llvm-bugs mailing list