Our project uses C++11/14, and we want to use nullptr
instead of 0
or NULL
with pointers, even when 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 with GCC (5.3.0) and the flag -Wzero-as-null-pointer-constant
it warnings in #2
, but I can't find a similar flag in Clang. If I compile the code with Clang (3.7.1) and the flag -Weverything
, I don't get any warning about #2
.
So, is there any way to get a similar warning for this in Clang?
!!!!!1
. – Hhd!!!!!1
is an integral constant expression (that evaluates tofalse
) and not an integer literal. – Provisionalnullptr
. – Litmus