[Bug c++/108335] New: New-expression doesn't perform mandatory copy elision when copy constructor is disabled with `requires`, in a template
iamsupermouse at mail dot ru
gcc-bugzilla@gcc.gnu.org
Sun Jan 8 08:02:59 GMT 2023
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`.
More information about the Gcc-bugs
mailing list