I found an interesting case where valid(?) C++17 code fails when compiling with C++20. The simplest reproduction is a struct with an explicit default constructor. On C++17, this code works fine. In C++20, it fails to compile. Tested on Clang and GCC.
struct A {
int val;
A() = default;
// When commented out: only works with C++17 or earlier
// When uncommented: works up to C++20
//A(int val) : val(val) { }
};
int main() {
A a{4};
}
Does anyone know why this is occurring?