https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108335
Bug ID: 108335 Summary: New-expression doesn't perform mandatory copy elision when copy constructor is disabled with `requires`, in a template Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iamsupermouse at mail dot ru Target Milestone: --- This doesn't compile, but it should: template <typename T> struct A { A(int) {} A(const A &) requires false {}; // The condititon can depend on `T`, it doesn't matter. }; template <typename> void foo() { new A<int>(A<int>(1)); } int main() { foo<int>(); } GCC says it doesn't have a suitable constructor to perform the copy. This starts working if I make `foo()` a non-template, or =delete `A(const A &)`, or create the object without `new`.