Related, but (IMHO) different: Nested template argument deduction for class templates not working
The following C++17 code is rejected from GCC 8, but clang compiles it without any issues. The GCC's error message is included as a comment just before the problematic line.
Which compiler is correct here?
template<class T>
struct Foo {
Foo(T) {}
};
template<class T>
struct Bar {
Bar(T) {};
};
void works() {
Bar bar{1};// {}
Foo foo(bar);// ()
}
void works_too() {
Foo foo{Bar{1}};// {{}}
}
void error_in_gcc() {
// error: 'auto' parameter not permitted in this context
Foo foo(Bar{1});// ({})
}
void but_this_works() {
Foo(Bar{1});// ({})
}