C++ Logo

std-discussion

Advanced search

Re: Is (0) a null pointer constant?

From: language.lawyer_at <language.lawyer_at_[hidden]>
Date: Fri, 21 Jul 2023 21:22:12 +0500
>> I guess this makes (0) a null pointer constant. I think [conv.ptr] can be made clearer by adding "(possibly parenthesized)" to the wording.
>
> I think the intent would be the opposite, and that compilers are actually too permissive with respect to [conv.ptr]. Looking at the last sentence in [expr.prim.parent] (https://eel.is/c++draft/expr.prim.paren):
>
> "...can be used in exactly the same contexts as those where E can be used, and with the same meaning, except as otherwise indicated."
>
> I think the intent of "except as otherwise indicated" encompasses the case of null pointer conversion.

Why?

> There are a few context in which a parenthesized expression has not the same meaning as the expression. On top of my head, I can think of 4 places in the standard where a parenthesized expression "(expr)" has not the same meaning as the operand expression "expr":
>
> - in "decltype(expr)": if expr is an id expression,
> then it changes the type result type.

`decltype` section says «unparenthesized id-expression»; «unparenthesized» is what makes it «otherwise indicated».

Received on 2023-07-21 16:22:18