https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65865
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> --- [hjl@gnu-6 gcc]$ cat /tmp/x.cc extern unsigned long indirect_call_wrapper; typedef unsigned long size_t; template <typename F> F IndirectExternCall(F f) { typedef F (*WrapF)(F); return indirect_call_wrapper ? ((WrapF)indirect_call_wrapper)(f) : f; } typedef void (*get_tls_func)(size_t*, size_t*) __attribute__((regparm(3), stdcall)); void foo (void *get_tls_static_info_ptr) { get_tls_func get_tls; __builtin_memcpy (&get_tls, &get_tls_static_info_ptr, sizeof(get_tls_static_info_ptr)); size_t tls_size = 0; size_t tls_align = 0; IndirectExternCall (get_tls)(&tls_size, &tls_align); } [hjl@gnu-6 gcc]$ ./xgcc -B./ -S -m32 -O2 /tmp/x.cc /tmp/x.cc: In function ‘void foo(void*)’: /tmp/x.cc:21:30: error: invalid conversion from ‘get_tls_func {aka void (__attribute__((stdcall, regparm(3))) *)(long unsigned int*, long unsigned int*)}’ to ‘void (*)(long unsigned int*, long unsigned int*)’ [-fpermissive] IndirectExternCall (get_tls)(&tls_size, &tls_align); ^ /tmp/x.cc:6:3: note: initializing argument 1 of ‘F IndirectExternCall(F) [with F = void (*)(long unsigned int*, long unsigned int*)]’ F IndirectExternCall(F f) { ^ [hjl@gnu-6 gcc]$