[Issue 18582] New: C++ namespace mangling from multiple modules doesn't use sequence ids
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 8 21:14:02 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18582
Issue ID: 18582
Summary: C++ namespace mangling from multiple modules doesn't
use sequence ids
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: C++, mangling
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at yahoo.com
discussion on the forum:
https://forum.dlang.org/post/tgzafcnjrdtkklefrsbz@forum.dlang.org
If there is a namespace that is declared in 2 different files, and a function
in the namespace in one file uses a type from the same namespace from another
file, instead of using a backreference (sequence id) in the name mangling for
the namespace of the parameter, it is incorrectly spelled out.
example:
lib.cpp:
namespace thenamespace
{
class class_a {
};
void some_function(class_a*) {;}
}
other.d:
extern (C++, thenamespace) {
class class_a {}
}
main.d:
import other;
extern (C++, thenamespace) {
void some_function(class_a);
}
void main() {
class_a instance_a;
thenamespace.some_function(instance_a);
}
build via:
g++ -c lib.cpp
dmd main.d other.d lib.o
Linker error:
Undefined symbols for architecture x86_64:
"thenamespace::some_function(thenamespace::class_a*)", referenced from:
__Dmain in main.o
If I use nm I see:
in main.o:
U __ZN12thenamespace13some_functionEPN12thenamespace7class_aE
in lib.o:
T __ZN12thenamespace13some_functionEPNS_7class_aE
Note the back reference S_ near the end of the symbol. I believe the reason it
doesn't happen for D's C++ mangler is because even though the namespace is
identical, it's a different D symbol from a different module.
This is shown by moving the declaration of class_a from other.d into main.d,
and compilation succeeds.
--
More information about the Digitalmars-d-bugs
mailing list