[cxx-abi-dev] Name mangling question
Martin v. Löwis
loewis at informatik.hu-berlin.de
Wed Nov 27 15:59:40 UTC 2002
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