namespace namespace

Andrew Haley aph@redhat.com
Tue Jul 7 20:17:00 GMT 2009


Ian Lance Taylor wrote:
> Andrew Haley <aph@redhat.com> writes:
> 
>> It turns out that the mangling of C++ keywords used by gcj is completely
>> broken:
>>
>> In particular, when a member name is a C++ keyword, "$" is appended to the
>> name.  However, this is results in an illegal mangled name so it is not
>> possible to refer to the member from CNI code.
>>
>> Also, the set of C++ keywords in gjavah is different from the set in gcj.
>>
>> Also, types are not checked for C++ keywords, so javax.xml.namespace.* cannot
>> be referenced from CNI code.
>>
>> This patch fixes the problem.
>>
>> This is an ABI change.  However, the ABI was almost completely broken
>> anyway.
> 
> Does this require any changes to the demangler? 

Good point.  I suppose that for really pedantic accuracy there should be, yes.

> Note that the demangler currently has a special case for this:
> 
>   /* A Java mangled name may have a trailing '$' if it is a C++
>      keyword.  This '$' is not included in the length count.  We just
>      ignore the '$'.  */
>   if ((di->options & DMGL_JAVA) != 0
>       && d_peek_char (di) == '$')
>     d_advance (di, 1);

How interesting.  I didn't know that.

I'm pretty sure that it can't possibly have worked, since there would have been
no way for CNI code to refer to methods or objects that had name components
that were C++ keywords.  Unless, perhaps, there was a similar hack in the C++
compiler, but what would have been the point?  Baffling.

Thanks,
Andrew.



More information about the Gcc-patches mailing list