Decorate C prototypes

Mark Mitchell mark@codesourcery.com
Sun May 3 23:06:00 GMT 2009


Martin Sebor wrote:

>> 2. We should verify that the compiler accepts
>>
>>   extern "C" void abort(void);
>>   namespace std {
>>     extern "C" void abort(void) throw();
>>   }

> gcc 4.3.1 (the latest I have access to at the moment) does accept
> this even though it's ill-formed according to [except.spec], p2:
> 
>   If any declaration of a function has an exception-specification,
>   all declarations, including the definition and an explicit
>   specialization, of that function shall have an exception-
>   specification with the same set of type-ids.

Yes, but I never remember if the standard explicitly says that the two
declarations above are for the same function.  In other words, how do
namespaces interact with extern "C"?

For the general case of extern "<some language>", AFAIK, the standard
doesn't suggest that namespaces don't matter.  In the general case, I
would expect that the language specification is just telling the
compiler things about the calling conventions and such -- but I'd not
expect that it fundamentally changes the C++ declaration so that
namespaces are irrelevant.

Of course, for extern "C" we all know that in practice that means "don't
mangle this function", which means that namespaces aren't useful.  But,
does the standard actually say that "::abort" and "std::abort" are the
same function in the example above?  Or are they different functions
which just happen to end up with the same mangled name?

> Bugs 32081 and 24817 look like they might be related to this
> problem:
> 
>   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32081
>   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24817

I think those are probably different issues (from the perspective of
what goes wrong in the guts of the compiler).

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Libstdc++ mailing list