www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14951] New: Win64: Invalid C++ mangling for __gshared pointer

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 puremagic.com
          Reporter: r.sagitario 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 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 Type  2PEAVClassDeclaration  A

--
Aug 23 2015