[cxx-abi-dev] RE: [cxx-abi] [cxx-abi-dev] Mangling unary plus

Mark Mitchell mark at codesourcery.com
Wed Oct 9 19:08:54 UTC 2002



--On Tuesday, October 08, 2002 01:28:21 PM -0700 "Nelson, Clark" 
<clark.nelson at intel.com> wrote:

>> For this example:
>>
>>   struct A { void operator+(); };
>>
>> what is the mangling of A::operator+?
>>
>> The current ABI spec says that "unary and binary operators using the
>> same symbol have different encodings" -- but does not actually specify
>> a mangling for unary plus, even though it does specify manglings for
>> unary minus, unary *, and unary &.
>>
>> G++ uses "ps" for unary plus.
>>
>> Intel, HP -- what do your compilers do?
>
> Intel's compiler uses "pl".

And so does HP's.

However, this encoding presents some problems.

Consider:

  A<(+3 + 4)>

This is going to end up encoded as (if my brain is mangling
corrctly today):

  AIXplplLi3ELi4EEE

if "pl" is used for both operators.

Nobody's demangler is going to get that right; you now need to be
writing scan-ahead code in your demangler to see how many arguments
there are.

And what about:

  A<(3 + (+4)) + 5>

  AIXplplLi3EplLi4ELi5EEE

vs:

  A<+3 + (4 + 5)>

  AIXplplLi3EplLi4ELi5EEE

Oops; those have the same mangling.  (Make it more interesting by
using other template constants, rather than numeric literals.)

So, I do not think we have a choice; I think we need to specify "ps"
for unary plus.

Thoughts?

-- 
Mark Mitchell                mark at codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com



More information about the cxx-abi-dev mailing list