https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86251
Bug ID: 86251 Summary: legal or illegal code? Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- Clang++ compiles the following code without any error messages: #include <utility> #include <iostream> using namespace std; template <typename _T, _T _V> void foo() { cout << __PRETTY_FUNCTION__ << endl; } int a = 0; int b() { cout << __PRETTY_FUNCTION__ << endl; } int main() { foo<int, 9>(); foo<int (), b>(); } In the contrast, gcc produces the following error message: ‘int()’ is not a valid type for a template non-type parameter foo<int (), b>(); A bug report of gcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6030) discusses more details of this issue. I believed that clang++ shall add the error message as g++ does, and reported the bug to https://bugs.llvm.org/show_bug.cgi?id=37829 However, Richard Smith believes that the code is legal, since int() decays to int(*)(), which is valid. His analysis seems to be contrary to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6030. Is this a bug in g++?