http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54813
Bug #: 54813 Summary: NULL pointer conversion fails for template code Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: tjab...@gmail.com int foo(int i); template<class Fun> static void bar(Fun fun, char[][sizeof(fun(0))]) {} void baz() { // With an explicit template parameter, 0 is converted to a multidimensional // array bar<int (*)(int)>(foo, 0); // succeeds // The template type is inferred when a has the right type. char a[4][sizeof(foo(0))]; bar(foo, a); // succeeds // Combining the two previous examples fails in g++ but is accepted by clang++. // Compilers that emit errors for this line: g++ 4.4.7, 4.5.3, 4.6.3 // Compilers that will compile this line: clang++ 3.2 bar(foo, 0); // failure } Error message with g++ 4.6.3: test.cc: In function ‘void baz()’: test.cc:9:13: error: no matching function for call to ‘bar(int (&)(int), int)’ test.cc:9:13: note: candidate is: test.cc:3:33: note: template<class Fun> void bar(Fun, char (*)[sizeof (fun(0))])