Date: Fri, 21 Jul 2023 11:09:59 +0100
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
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
Received on 2023-07-21 10:10:05