Consider the following code:
auto f() -> decltype(int{0.}, void()) { }
int main() { f(); }
It doesn't compile (as expected) with an error:
narrowing conversion of '0.0' from 'double' to 'int' inside { }
Both GCC and clang agree on that.
Now consider the code below:
template <typename T>
auto f(T) -> decltype(int{0.}, void()) { }
int main(){
f(0);
}
In this case, clang 3.9 returns an error and GCC 6.2 compiles with no errors.
Is there any reason for which the narrowing conversion should be accepted in case of a function template or is it an error of GCC?
I'm going to open an issue to GCC for I guess it should fail to compile, but I would like to know if I'm missing something important about function template here.
f
it would be ill-formed NDR. – Crackerjack