https://godbolt.org/z/Gsqs1vo5P, original issue: https://stackoverflow.com/q/77788861/5740428
struct A {
explicit A(int = 0);
// A()= default;
} a = {};
Clang considers this ill-formed both if you comment out the second constructor uncomment it. In its current state, clang emits:
<source>:4:3: error: chosen constructor is explicit in copy-initialization
4 | } a = {};
| ^ ~~
<source>:2:12: note: explicit constructor declared here
2 | explicit A(int = 0);
| ^
When uncommenting the second constructor, we get:
<source>:4:3: error: call to constructor of 'struct A' is ambiguous
4 | } a = {};
| ^ ~~
<source>:2:12: note: candidate constructor
2 | explicit A(int = 0);
| ^
<source>:3:3: note: candidate constructor
3 | A()= default;
| ^
This is nonsensical. A(int) can't simultaneously
- be viable and cause an ambiguous overload, and
- be non-viable and cause
= {} to be ill-formed when it's the only overload.