Which Clang warning is equivalent to GCC's Wzero-as-null-pointer-constant?

Our project uses C ++ 11/14, and we want to use nullptr instead of 0 or NULL with pointers, even if 0 (as an integer literal) is allowed.

I have the following code:

 int main() { int *ptr1 = nullptr; // #1 int *ptr2 = 0; // #2 } 

If I compile GCC (5.3.0) and the -Wzero-as-null-pointer-constant flag, these are warnings in #2 , but I cannot find a similar flag in Clang. If I compile the code using Clang (3.7.1) and the -Weverything flag, I do not receive a warning about #2 .

So, is there a way to get a similar warning for this in Clang?

+6
source share
2 answers

Clang does not support these warnings (i.e. there is no equivalent to -Wzero-as-null-pointer-constant in Clang). You can see this for yourself if you add the -Weverything option (do not do this just for testing), which allows all Clang warnings.

Live demo

+4
source

clang has this warning since 5.0; I added it here http://llvm.org/viewvc/llvm-project?view=revision&revision=302247 .

+3
source

All Articles