Pointer to member function mangling

Jason Merrill jason at redhat.com
Wed Jan 30 11:43:09 UTC 2002


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.

  ...

  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.  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

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

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?

Jason



More information about the cxx-abi-dev mailing list