With trunk G++: $ ~/gcc/bin/g++ --version g++ (GCC) 4.6.0 20100901 (experimental) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat fdc.cc extern void cf(); // no warning void *f() { return __extension__ (void *) cf; } // warning: // ISO C++ forbids casting between pointer-to-function and pointer-to-object template<bool flag> void *ft() { return __extension__ (void *) cf; } template void *ft<true>(); $ LD_LIBRARY_PATH=$HOME/gcc/lib ~/gcc/bin/g++ -Wall -pedantic -c fdc.cc fdc.cc: In function void* ft() [with bool flag = true]: fdc.cc:11:25: instantiated from here fdc.cc:9:44: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [enabled by default] I would expect G++ to either complain about both casts, or neither; whether the code appears in a function template shouldn't matter. -- Summary: G++ permits function-to-data pointer conversions with __extension__ in functions, but not function templates Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jimb at red-bean dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45492