GCC 7 will be released soon. The GCC 7 release notes states the following under C Family:
-Wpointer-compare
warns when a pointer is compared with a zero character constant. Such code is now invalid in C++11 and GCC rejects it. This warning is enabled by default.
I feel like I am missing a nuance to the issue at hand (or worse, something obvious). What are zero character constants? How do they create trouble for C and C++?
Here's a few related C++ questions. The answers have improved over time, and point out things like Stroustrup prefers comparing to 0
and sizeof(int) != sizeof(void*)
. But they don't discuss the zero character constants.
- Do you use NULL or 0 (zero) for pointers in C++?
- Checking for NULL pointer in C/C++
- Can I use if (pointer) instead of if (pointer != NULL)?
- How do we check if a pointer is NULL pointer?
Aucun commentaire:
Enregistrer un commentaire