On 2022-05-22 at 23:58, Andrey Semashev via Boost wrote:
On 5/22/22 18:35, Peter Dimov wrote:
I did however not know that GCC doesn't warn on NULL. Interesting compromise, even though I don't quite see the point of it.
Clang does warn on NULL, however.
I do see the point of it now. Under GCC the warning is pragmatically intended to catch actual mistakes such as mistyping
while( *p != 0 )
as
while( p != 0 )
so the warning only triggers on the actual 0, and is enabled under C++03 as well.
Clang, and the various static analysis tools such as the MS analyzer, enforce a stylistic preference for nullptr, so they warn on both 0 and NULL, but Clang doesn't warn in C++03 mode.
Either way, I'm not looking forward to adding a bunch of lines to suppress the various warnings, instead of just telling the PR author to use BOOST_NULLPTR instead of nullptr.
We already have NULL as the portable macro, so I would still prefer it to a Boost invention.
Again, that some compilers warn on NULL is a compiler bug and should be treated as such, IMO. Compiler vendors should keep their stylistic preferences to themselves, especially when they are impossible to follow (in C++03 case). The use of NULL as a null pointer is perfectly valid, in the sense of both formal C++ compliance and code readability.
This happens when you write the code for C++03, but compile it for C++20. I think it is pretty nice of the compiler to hint that things have changed in the last 20 years.