[cxx-abi-dev] Mangling of anonymous unions

Richard Smith richardsmith at google.com
Mon Dec 9 21:46:26 UTC 2013


Hi!

5.1.2 says: "For the purposes of mangling, the name of an anonymous union
is considered to be the name of the first named data member found by a
pre-order, depth-first, declaration-order walk of the data members of the
anonymous union."

5.1.6 says: "In case of unnamed local types (excluding unnamed types that
have acquired a "name for linkage purposes"), the "name" the unqualified
name is encoded as an <unnamed-type-name>"

Thus, given:

struct A { union { int n; }; struct {} x; };
template<int A::*> struct X {};
void f(X<&A::n>, decltype(A::x)) {}

... the mangling of 'f' is _Z1f1XIXadL_ZN1A1n1nEEEENS0_Ut_E

However, I can't find any implementation that actually follows these rules.

Clang and GCC give the anonymous union an unnamed type mangling instead of
an anonymous union mangling, and give _Z1f1XIXadL_ZN1AUt_1nEEEENS0_Ut0_E

EDG follows the 5.1.6 rule but doesn't seem to implement the 5.1.2 rule,
and instead gives _Z1f1XIXadL_ZN1A4__C11nEEEENS0_Ut_E


What's the purpose of the special case in 5.1.2 and 5.1.6? The rules would
be simpler and more uniform if we adopted the Clang and GCC behavior, and
we don't seem to lose much by doing so. Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20131209/98cb8207/attachment.html>


More information about the cxx-abi-dev mailing list