------- Comment #7 from mmitchel at gcc dot gnu dot org 2006-10-06 19:18 ------- I'm following up to the mailing list in the PR trail, since it's very confusing to go back and forth between the two.
The technical issue is that in the following code: extern "C" { typedef void (*p1)(); } typedef void (*p2)(); p1 and p2 are distinct types, and, in fact, you can overload based on that. G++ doesn't implement that distinction; we don't keep track of language linkage for types (just for functions) but we should, and, at some point, I'm sure we'll implement that. The reason this is in the standard is so that an implementation can use different calling conventions for C and C++. So, when calling through a function pointer you have to know which kind of function you're calling. (And, yes, name-mangling is supposed to encode the linkage of the function type, when mangling a pointer-to-function type.) So, changing the linkage of __cxa_cdtor_return_type (that name is not specified in the ABI, by the way), technically changes the type of __cxa_vec_new. However, the ABI specification does say that __cxa_vec_new is declared extern "C", and, since it specifically gives this prototype: extern "C" void * __cxa_vec_new ( size_t element_count, size_t element_size, size_t padding_size, void (*constructor) ( void *this ), void (*destructor) ( void *this ) ); that means that the type of the constructor and destructor arguments are also required to be pointers-to-C-functions. In summary, I think Benjamin's proposed change (to change the constructor type to have extern "C" linkage) is in fact required by the ABI. Although it's technically a source-incompatible change, since G++ doesn't implement linkage for function pointers, there's no way that a user of G++ can tell the difference. Therefore, I think that's the right thing to do. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29095