[Issue 14951] New: Win64: Invalid C++ mangling for __gshared pointer variables

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 23 08:37:48 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14951

          Issue ID: 14951
           Summary: Win64: Invalid C++ mangling for __gshared pointer
                    variables
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

Compile this file with the x64 MC compiler:

// testcpp.cpp
class ClassDeclaration
{
};

extern ClassDeclaration* ti2;

class Type
{
public:
    static ClassDeclaration* typeinfovector;
};

ClassDeclaration* foo()
{
    return ti2 ? ti2 : Type::typeinfovector;
}

and link with

// test.d
extern(C++) class ClassDeclaration
{
}

extern(C++) class Type
{
    static __gshared ClassDeclaration typeinfovector;
}

extern(C++) __gshared ClassDeclaration ti2;

extern(C++) ClassDeclaration* foo();

void main()
{
    foo();
}

///////////////////
cl /c testcpp.cpp
dmd -m64 test.d testcpp.obj

test.obj : error LNK2019: unresolved external symbol "class ClassDeclaration *
*
 __cdecl foo(void)" (?foo@@YAPEAPEAVClassDeclaration@@XZ) referenced in
function
 _Dmain
testcpp.obj : error LNK2019: unresolved external symbol "class ClassDeclaration
* ti2" (?ti2@@3PEAVClassDeclaration@@EA) referenced in function "class
ClassDecl
aration * __cdecl foo(void)" (?foo@@YAPEAVClassDeclaration@@XZ)
testcpp.obj : error LNK2019: unresolved external symbol "public: static class
Cl
assDeclaration * Type::typeinfovector"
(?typeinfovector at Type@@2PEAVClassDeclarat
ion@@EA) referenced in function "class ClassDeclaration * __cdecl foo(void)"
(?f
oo@@YAPEAVClassDeclaration@@XZ)

The dmd generated symbols are missing the "E" modifier for the pointer type:

?ti2@@3PEAVClassDeclaration@@A
?typeinfovector at Type@@2PEAVClassDeclaration@@A

--


More information about the Digitalmars-d-bugs mailing list