Consider the following example that compiles with clang but is rejected by clang,gcc and msvc. Demo
#include <initializer_list>
struct C
{
C(){}
C(std::initializer_list<int> i = {3})
{
}
};
int main()
{
C d{}; //clang:Ok, gcc:No, MSVC: No, EDG: No
}
As we can see clang accepts the code while gcc and others reject it. GCC says:
<source>: In function 'int main()':
<source>:20:9: error: call of overloaded 'C(<brace-enclosed initializer list>)' is ambiguous
20 | C d{}; //clang:Ok, gcc:No, MSVC: No, EDG: No
| ^
<source>:10:5: note: candidate: 'C::C(std::initializer_list<int>)'
10 | C(std::initializer_list<int> i = {3})
| ^
<source>:6:5: note: candidate: 'C::C()'
6 | C()
| ^
I want to know which compiler is correct here as per the latest standard.