gcc(trunk) for this code: #include <iostream> template <typename T> int foo(int) { return 1; } template <typename T> int foo(decltype(T{})) { return 2; } template <typename T> int foo(decltype(int(T{}))) { return 3;} int main() { std::cout << foo<int>(0); } prints '2'. But as I understand here should be compilation error because of ambiguous call to overload function
Clang also compiles it, and prints "1". EDG rejects it as ambiguous: "a.cc", line 8: error: more than one instance of overloaded function "foo" matches the argument list: function template "int foo<T>(int)" function template "int foo<T>(int)" argument types are: (int) return foo<int>(0); ^ 1 error detected in the compilation of "a.cc".
Seems fixed in GCC 11+.
Fixed with r11-123-ge42f342652981aa9.