C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] nullptr + 0

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Thu, 26 Oct 2023 14:41:18 +0200
On 26/10/2023 14.29, Robert Seacord via Liaison wrote:
>
> Does anyone know why |nullptr + 0| is defined in C++ but not C?

What makes you believe "nullptr + 0" to be well-formed in C++?

At least two compilers (gcc, clang) agree it's not:

x.cc:4:22: error: invalid operands of types ‘std::nullptr_t’ and ‘int’ to binary ‘operator+’
    4 | void * p = nullptr + 0;
      | ~~~~~~~~^~~

Jens

Received on 2023-10-26 12:41:24