D's insufficient name mangling
Thomas Kuehne
thomas-dloop at kuehne.cn
Wed Nov 8 15:39:04 PST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Apart from implementation issues like #211, #375 and #466,
D's current name mangling achieves the primary target:
> Make it possible for linkers to distinguish between different
> versions of overloaded functions.
However it fails to address the consistency issue:
> Make it possible for linkers to check that objects and
> functions are declared in exactly the same way in all modules.
The problem is that it isn't reversible,
causing all kinds of problems for runtime reflections.
issue 1: missing "static" information
#
# class C{
# void foo(){}
# static void bar(){}
# }
#
_D8mangling1C3fooFZv
_D8mangling1C3barFZv
issue 2: missing "struct"/"union" information
#
# union Cat { int i; }
# struct Cow { int i; }
#
# Cat foo() { assert(0); }
# Cow bar() { assert(0); }
_init_8mangling3Cat
_init_8mangling3Cow
_D8mangling3fooFZS8mangling3Cat
_D8mangling3barFZS8mangling3Cow
issue 3: missing "const" information
#
# int X = 0;
# const int Y = 0;
#
_D8mangling1Xi
_D8mangling1Yi
issue 4: missing protection attributes
While the ELF object format used by Linux supports differentiation
of "private" and "public" (though see issue #463),
"package" and "protected" can't be differentiated.
issue 5: missing "final" information
#
# class C{
# final void foo() {}
# void bar() {}
# }
#
_D8mangling1C3fooFZv
_D8mangling1C3barFZv
Especially the "static" and "struct"/"enum" issues pose a problem for
runtime reflection due to their effects on calling conventions.
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFUndcLK5blCcjpWoRArDfAJ48mM7rnA5kMOTQ2hNa/fAcK2wrNwCbB4C8
8oy2C9UVZeb0Hl4vaeKoKdI=
=SqZb
-----END PGP SIGNATURE-----
More information about the Digitalmars-d
mailing list