Please consider following C++20 program:
#include <iostream>
struct A
{
A() {}
A( const A& ) = delete;
A( A&& ) { std::cout << "m "; }
};
int main() {
[[maybe_unused]] A a = {{A{}}};
}
I expected that move elision is required here according to the standard, so A( A&& )
will not be called. Still Clang calls it: https://gcc.godbolt.org/z/oobh7vWoh
Could you please clarify whether it is really permitted or not by the standard?
P.S. There is a similar question Copy elision for list-initialization, where is it stated in the standard? but it differs from this one by initializer_list
constructor, so I do not think this one is a duplicate.