Copy/move elision in case of delegating to a copy/move constructor

Viewed 86

In the following program, the constructor A::A(int) delegates the call to copy/move constructor, which both are explicitly deleted:

struct A;
A f();

struct A {
    A() {}
    A(int) : A(f()) {}
    A(const A&) = delete;
    A(A&&) = delete;
};

Still both GCC and MSVC accept the program without a warning. I suppose that they do it considering copy/move elision rules.

But Clang rejects the program with the

error: call to deleted constructor of 'A'

Demo: https://gcc.godbolt.org/z/MjGMaeGrn

Which compiler is right here?

0 Answers
Related