This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13316] g++ does not follow mangling ABI for pointer to qualified member function
- From: "ian at wasabisystems dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jan 2004 22:57:49 -0000
- Subject: [Bug c++/13316] g++ does not follow mangling ABI for pointer to qualified member function
- References: <20031205150837.13316.ian@airs.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From ian at wasabisystems dot com 2004-01-11 22:57 -------
Subject: Re: g++ does not follow mangling ABI for pointer to qualified member function
"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:
> I agree with your reading of the ABI. Let's pretend for a moment we want to fix
> this one: I made a patch which makes GCC emits this:
>
> _Z1rM1GFivEMS_KS0_S_M1HFivES1_4whatIKS_E5what2IS8_ES3_
>
> It's still not 100% perfect because there is a "FivE" occurrence which is not
> substitued by S0_, but it looks better. The output of the demangler is:
>
> r(int (G::*)(), int ()() const G::*, G, int (H::*)(), int (G::*)(), what<G
> const>, what2<G const>, int ()() const G::*)
>
> which looks wrong. It seems that not even the demangler is ready to handle
> substitutions in that context.
Yes, that is inevitable. The demangler and the compiler have to agree
on the substitution algorithm. I know of two demanglers, and both of
them follow the algorithm used by gcc. The demangler has no way to
figure out the substitution algorithm on the fly.
This means that, if gcc is changed, the demanglers will require a user
option to demangle older names correctly.
In the libiberty demangler I wrote this comment:
/* The ABI specifies that any type can be a substitution source, and
that M is followed by two types, and that when a CV-qualified
type is seen both the base type and the CV-qualified types are
substitution sources. The ABI also specifies that for a pointer
to a CV-qualified member function, the qualifiers are attached to
the second type. Given the grammar, a plain reading of the ABI
suggests that both the CV-qualified member function and the
non-qualified member function are substitution sources. However,
g++ does not work that way. g++ treats only the CV-qualified
member function as a substitution source. FIXME. So to work
with g++, we need to pull off the CV-qualifiers here, in order to
avoid calling add_substitution() in cplus_demangle_type(). */
In the libstdc++ demangler, Carlo wrote this:
// It is unclear why g++ doesn't add a substitution for
// "<Q2>F<R><B>E" as it should I think.
Ian
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13316