[cxx-abi-dev] Name mangling question

nasgaard at ca.ibm.com nasgaard at ca.ibm.com
Wed Nov 27 16:35:10 UTC 2002


Martin,  Your observation may be the key here.  we are mangling ::locale::
_Impl.  Is the following sequence of productions correct?

<nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E    <<
there is no substitution here.  _Impl is the unqualified name
   <prefix> ::= <prefix> <unqualified-name>
<< here we would subst S_ for locale which we've seen
      <prefix> ::= empty

This would yield NS_5ImplE.


Howard W. Nasgaard
C++ Compiler Development
e-mail: nasgaard at ca.ibm.com
C2/KD2/8200/MKM
905-413-3683
Tie: 969-3683



                                                                                                                                                    
                      loewis at informatik.h                                                                                                           
                      u-berlin.de (Martin        To:       Howard Nasgaard/Toronto/IBM at IBMCA                                                        
                      v. Löwis)                  cc:       cxx-abi-dev at codesourcery.com                                                             
                                                 Subject:  Re: [cxx-abi-dev] Name mangling question                                                 
                      11/27/2002 10:59 AM                                                                                                           
                                                                                                                                                    
                                                                                                                                                    



nasgaard at ca.ibm.com writes:

> I expect _ZN6locale5_Impl3fooERNS_5_ImplE, based on the set of
productions
> as stated in my original note.  I think g++ is missing the fact that it
is
> nested.  There is no N...E in the name.  If I run that mangled name
through
> c++filt I get locale::_Impl::foo(locale::_Impl&), as I would expect.
Which
> one is right and why?  They can't both be right.

The first question is whether both these manglings follow the
grammar. This is indeed the case, in <type>, we have

  R <type>

so R is followed by a type. One alternative for <type> is
<substitute>, so

  R S0_

is clearly a valid mangling for a type. I assume you agree that your
proposed mangling is also possible for that grammar.

Now, the question is which of these manglings is the correct one.

As you indicate,

S_  is ::locale
S0_ is ::locale::_Impl

In 5.1.7, the ABI spec says

# Logically, the substitutable components of a mangled name are
# considered left-to-right, components before the composite structure
# of which they are a part. If a component has been encountered
# before, it is substituted as described below. This decision is
# independent of whether its components have been substituted, ...

For locale::_Impl, we first check for ::locale, and subsitute this as
S_::_Impl. Then we consider the composite structure,
i.e. ::locale::_Impl, which also has been encountered before. So we
clearly must replace ::locale::_Impl with S0_ (even though the
::locale component has already been substituted). The intention here
is to always substitute as large structures as possible.

Now the question might be whether to mangle this as NS0_E or just as
S0_. Of those, only S0_ is allowed, since, in a <nested-name>, you
must have an <unqualified-name> or <template-args> after a
<substitution>.

So the g++ mangling is correct, and your proposed mangling is
incorrect.

Regards,
Martin






More information about the cxx-abi-dev mailing list