I have such code
struct Foo {
Foo() {}
Foo(std::initializer_list<Foo>) {
std::cout << "initializer list" << std::endl;
}
Foo(const Foo&) {
std::cout << "copy ctor" << std::endl;
}
};
int main() {
Foo a;
Foo b(a);
Foo c{a};
}
Compiling it with g++ -std=c++20 -o main main.cpp
and running gives me such output:
copy ctor
copy ctor
initializer list
But running binary compiled with clang++ -std=c++20 -o main main.cpp
outputs the following:
copy ctor
copy ctor
So why are those two outputs are different?