[Bug c++/107260] New: The prvalue with the value 0 that is not a integer literal shouldn't convert to std::nullptr_t

xmh970252187 at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Oct 14 09:35:17 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107260

            Bug ID: 107260
           Summary: The prvalue with the value 0 that is not a integer
                    literal shouldn't convert to std::nullptr_t
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

[conv.ptr] p1 says
> A null pointer constant is an integer literal ([lex.icon]) with value zero 

> A null pointer constant of integral type can be converted to a prvalue of type std​::​nullptr_­t.

GCC accept this example
````cpp
std::nullptr_t v = (int)0;
````
However, the initializer expression is not an integer literal, it is a prvalue
of integer type with the value 0. It should be rejected. Clang rejects this
example. https://godbolt.org/z/fxMo4YKE3


More information about the Gcc-bugs mailing list