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

            Bug ID: 125546
           Summary: GCC accepts a variable template definition that
                    initializes int from nullptr
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qurong at ios dot ac.cn
  Target Milestone: ---

GCC 15.2.0 accepts the following C++20 program, while Clang 22 rejects it:

template<typename T>
int abc_template = nullptr;

GCC:gcc15 15.2.0
-std=c++20: accepts
-std=c++20 -pedantic-errors: accepts

Clang: clang++-22 22.0.0
-std=c++20: rejects
-std=c++20 -pedantic-errors: rejects

Clang diagnostic:
error: cannot initialize a variable of type 'int' with an rvalue of type
'std::nullptr_t'

Reply via email to