<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73449>73449</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-Wzero-as-null-pointer-constant` not reported with clang-tidy
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
#include <cstddef>
void test()
{
int* p = NULL;
}
```
```
$ clang -Wzero-as-null-pointer-constant test.cpp
test.cpp:5:11: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
int* p = NULL;
^~~~
nullptr
/usr/lib/clang/16/include/stddef.h:84:18: note: expanded from macro 'NULL'
# define NULL __null
^
```
```
$ clang-tidy -checks='*' -extra-arg=-Wzero-as-null-pointer-constant test.cpp
2335 warnings generated.
/home/user/test.cpp:1:1: warning: system include cstddef not allowed [llvmlibc-restrict-system-libc-headers]
#include <cstddef>
^~~~~~~~~~~~~~~~~~
/home/user/test.cpp:3:6: warning: declaration must be declared within the '__llvm_libc' namespace [llvmlibc-implementation-in-namespace]
void test()
^
/home/user/test.cpp:5:7: warning: variable name 'p' is too short, expected at least 3 characters [readability-identifier-length]
int* p = NULL;
^
/home/user/test.cpp:5:11: warning: use nullptr [modernize-use-nullptr]
int* p = NULL;
^~~~
nullptr
Suppressed 2331 warnings (2331 in non-user code).
```
Strangely in Godbolt the warning is not reported with the compiler: https://godbolt.org/z/hGjG1YM7o
True, `modernize-use-nullptr` and `-Wzero-as-null-pointer-constant` are checking for the same thing but I did not expect that the compiler warning is disabled. I wonder if other warnings are being suppressed as well. I have seen the same "issue" for the same line for other checks in the past.
In our case we have `modernize-use-nullptr` disabled since it duplicates the compiler warning and we use the clang-tidy step in the CI as the step which is supposed to fail on compiler warnings as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVltv2zgT_TX0y0CGTF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