I forgot to mention, the fact that compilers are permissive on the null pointer conversion is most likely some kind of leftover from C, which has implicit conversion from integral expression to pointer type.


On July 21, 2023 6:09:59 a.m. EDT, "Lénárd Szolnoki via Std-Discussion" <std-discussion@lists.isocpp.org> wrote:
On Fri, 2023-07-21 at 14:48 +0500, language.lawyer--- via Std-
Discussion wrote:
Is a parenthesised integer literal with value zero a null pointer
constant?

The current wording doesn't seem to allow that. [conv.ptr] says
that "a
null pointer constant is an integer literal ([lex.icon]) with value
zero ...", which should exclude (0).

All of gcc, clang and MSVC accept `void * ptr = (0);`.

https://timsong-cpp.github.io/cppwp/n4868/expr.prim.paren#1.sentence-2
: The parenthesized expression can be used in exactly the same
contexts as those where E can be used, and with the same meaning,
except as otherwise indicated.

Thank you, I guess this makes (0) a null pointer constant. I think
[conv.ptr] can be made clearer by adding "(possibly parenthesized)" to
the wording. But this is purely editorial.

Cheers,
Lénárd