Bug 13337 – Invalid extern C++ namespace resolution
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-08-20T06:24:00Z
Last change time
2015-03-25T03:26:30Z
Keywords
C++
Assigned to
nobody
Creator
chatelet.guillaume
Comments
Comment #0 by chatelet.guillaume — 2014-08-20T06:24:05Z
Consider this C++ code :
namespace A {
namespace B {
struct Type {};
int foo(Type unused){ return 42; }
} // namespace B
} // namespace A
Now this D code uses foo :
extern(C++, A.B) {
struct Type {}
int foo(Type unused);
}
void main() {
foo(Type());
}
Compilation gives :
cpp_namespace.d:(.text._Dmain+0x11): undefined reference to `A::B::foo(A::Type)'
Type is resolved in A and not in A.B
Specifying the full name doesn't help and gives the same result
extern(C++, A.B) {
struct Type {}
int foo(A.B.Type unused);
}
void main() {
A.B.foo(A.B.Type());
}
Comment #1 by chatelet.guillaume — 2015-01-21T16:18:43Z
Specifying the mangling explicitely does work though
extern(C++, A.B) {
struct Type {}
pragma(mangle,"_ZN1A1B3fooENS0_4TypeE") int foo(Type unused);
}
Comment #2 by chatelet.guillaume — 2015-01-24T10:16:32Z
Digging into it, it looks like a parsing issue and not a mangling issue.
Comment #3 by github-bugzilla — 2015-01-24T23:38:47Z