A complexity in the mangling ABI

Ian Lance Taylor ian at wasabisystems.com
Sun Nov 23 23:40:43 UTC 2003


The mangling ABI says this:

``For purposes of substitution, given a CV-qualified type, the base
  type is substitutible, and the type with all the C, V, and r
  qualifiers plus any vendor extended types in the same
  order-insensitive set is substitutible; any type with a subset of
  those qualifiers is not.  That is, given a type const volatile foo,
  the fully qualified type or foo may be substituted, but not volatile
  foo nor const foo.  Also, note that the grammar above is written
  with the assumption that vendor extended type qualifiers will be in
  the order-sensitive (not CV) set.  An appropriate grammar
  modification would be necessitated by an order-insensitive vendor
  extended type qualifier like const or volatile.''

What I'm thinking about here is the language about vendor extended
type qualifiers.  This paragraph states clearly that if a type has
more than one order-insensitive qualifier, the base type is
substitutable, and the base type with all of the qualifiers is
substitutable, but the base type with a subset of the qualifiers is
not substitutable.

The ABI also says ``Vendors must therefore specify which of their
extended qualifiers are considered order-insensitive....''

This implies that some vendor extended type qualifiers may be
order-sensitive.  The first paragraph implies that if a vendor
extended type qualifier is order sensitive, then it is permissible to
subset that qualifier--the restriction on subsetting refers only to
order-insensitive qualifiers.

This means that a demangler must be able to distinguish between an
order-sensitive vendor extended type qualifer and an order-insensitive
vendor extended type qualifier.  Otherwise it is impossible to
correctly handle substitutions.

The first paragraph quoted above suggests that an order-insensitive
vendor extended type qualifier would require a grammar modification.
However, I can't see why.  The <type> nonterminal permits any ordering
between a vendor extended type qualifier and a set of CV-qualifiers.

I believe that all of the V3 demanglers I am aware of resolve this
issue by assuming that all vendor extended type qualifiers are
order-insensitive, and thus that when multiple vendor extended type
qualifiers are present, or when a vendor extended type qualifier is
used with one or more CV-qualifiers, the type may be subset for
purposes of substitution.

Without assuming that all vendor extended type qualifiers are
order-insensitive, I believe that it is possible to write a demangler
which is not aware of all vendor extended type qualifiers, which is
obviously impossible.

This is all a long-winded way of asking why the ABI says that
order-insensitive vendor extended type qualifiers may not be subset
for purposes of substitution.  If this restriction were lifted--if
only the standard CV-qualified type could not be subset--then I
believe that it would be possible to write a correct demangler which
was not aware of all vendor extended type qualifiers.

For the record, I believe that g++ emits only one vendor extended type
qualifier, namely __vector, and g++ emits it as though it were
order-sensitive, at least for purposes of substitution.

Thanks.

Ian



More information about the cxx-abi-dev mailing list