[llvm-bugs] [Bug 44325] New: Wzero-as-null-pointer-constant warns when using `operator<=>`
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 17 12:30:12 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44325
Bug ID: 44325
Summary: Wzero-as-null-pointer-constant warns when using
`operator<=>`
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: david at doublewise.net
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
```
#include <compare>
auto b = 1 <=> 2 < 0;
```
Outputs:
```
<source>:3:20: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
auto b = 1 <=> 2 < 0;
^
nullptr
1 warning generated.
Compiler returned: 0
```
See it live: https://godbolt.org/z/9a8cnD
Technically, the warning is accurate. User code has a literal `0` that is being
passed to a function accepting a `nullptr`. However, this is an implementation
detail of the standard library and the intended interface for use (users should
not use `nullptr` there), so we should not warn users for doing so (and
definitely should not direct them to change their code).
--
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/20191217/003f043e/attachment.html>
More information about the llvm-bugs
mailing list