Consider the following code:
auto f() -> decltype(int{0.}, void()) { } int main() { f(); }
It will not compile (as expected) the error:
narrowing the conversion of '0.0' from 'double' to 'int' inside {}
Both GCC and clang agree on this.
Now consider the following code:
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 without errors.
Is there a reason why narrowing the conversion should be taken in the case of a function template or is it a GCC error?
I am going to open the problem for GCC because, in my opinion, it should not compile, but I would like to know if there is something important missing in the function template.
c ++ c ++ 11 templates decltype
skypjack
source share