[cxx-abi-dev] Pointer to member function mangling

Daveed Vandevoorde daveed at edg.com
Wed Jan 30 14:32:52 UTC 2002


Jason Merrill wrote:
> 
> The ABI says
> 
>   Names of objects nested in namespaces or classes are identified as a
>   delimited sequence of names identifying the enclosing scopes. In addition,
>   when naming a class member function, CV-qualifiers may be prefixed to the
>   compound name, encoding the this attributes. Note that if member function
>   CV-qualifiers are required, the delimited form must be used even if the
>   remainder of the name is a single substitution.
> 
>       <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
>                       ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
> 
>   ...
> 
>   [in the function type section]
>   If there are any cv-qualifiers of this, they are encoded at the beginning
>   of the <qualified-name> as described above.

I don't think the latter was meant to apply to pointer-to-member types, which
(as you quote below) disocciate the class ("this") type from the member
type.

>   ...
> 
>   Pointer-to-member types encode the class and member types.
> 
>     <pointer-to-member-type> ::= M <class type> <member type>
> 
> Let me just start by saying that I think the first bit above was a mistake,
> as the CV-quals are an attribute of the function type, not the class or
> function name.  But I suppose that since we don't mention the function type
> directly, we can't qualify it. 

I remember we discussed that. I agree it's unfortunate, but I'm not
sure it's a mistake.

> In any case, a function like
> 
>   void A::f () const
> 
> would be encoded
> 
>   _ZNK1A1fEv
> 
> My question has to do with encoding a cv-qualified pointer to member
> function type, i.e.
> 
>   void (A::*)() const
> 
> g++ currently emits
> 
>   MK1AFvvE
> 
> or, member of class "const A" of type "function of (void) returning void".
> I don't see how this can be deduced from the above text.  More consistent
> with the handling of function names, and suggested by the text in the
> function type section, would be
> 
>   MNK1AEFvvE

I don't see that: there is no <nested-name> in the pointer-to-member
above.

> or, member of "A with member function-modifying const" of type "function of
> (void) returning void".
> 
> IMO more consistent with the language semantics would be
> 
>   M1AKFvvE

That is what I would expect and what I actually read in the specification
if I squint right:
	M <class type> <member type>
	<class type> :: 1A
	<member type> :: K FvvE

> or, member of A of type "function of (void) const returning void".  The C++
> standard states unambiguously that the cv-quals are part of the function
> type.
> 
> Looking over the mailing list archives, I was unable to find any discussion
> of this issue, though it was mentioned in passing a couple of times.
> 
> What do other compilers produce?  What do other demanglers expect?

As a human demangler, I expect your last form.

	Daveed



More information about the cxx-abi-dev mailing list