[Bug c++/51936] template function not instantiated

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Jan 21 20:32:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51936

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-21 20:23:27 UTC ---
The standard says in [expr.reinterpret.cast]
"A function pointer can be explicitly converted to a function pointer of a
different type. The effect of calling a function through a pointer to a
function type (8.3.5) that is not the same as the type used in the definition
of the function is undefined."

So I think the program has undefined behaviour.  Because you never call
asd<int,0> as part of a valid expression it doesn't need to be instantiated.


Clang++ fails in the same way as G++ 4.6, but it works with G++ 4.7



More information about the Gcc-bugs mailing list