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

            Bug ID: 125563
           Summary: GCC accepts a default argument that invokes a deleted
                    constructor in a class template
           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 program in -std=c++20, including with
-pedantic-errors:

struct X {
  X() = delete;
};

template <int>
struct O {
  struct I {
    I(const X& = X());
  };
};

template struct O<2>;


Clang 22 rejects the same code with:
error: call to deleted constructor of 'X'

Commands
g++ -std=c++20 -pedantic-errors -c test.cpp
clang++ -std=c++20 -pedantic-errors -c test.cpp

Actual behavior
GCC 15.2.0: accepts
Clang 22.0.0: rejects

Expected behavior
The program should be rejected, because the default argument X() attempts to
call a deleted constructor.

Reply via email to