Bug 15608 – extern(C++) mangling problem

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2016-01-26T04:12:54Z
Last change time
2019-06-10T04:49:46Z
Keywords
C++, industry, mangling
Assigned to
No Owner
Creator
Manu

Comments

Comment #0 by turkeyman — 2016-01-26T04:12:54Z
C++: class IComponent { virtual Variant CallMethod(String method, Slice<const Variant> args) = 0; }; class Component : public IComponent { Variant CallMethod(String method, Slice<const Variant> args) override final; }; D: extern(C++) interface IComponent { Variant CallMethod(String method, Slice!(const(Variant)) args); } extern (C++) class Component : IComponent { final override Variant CallMethod(String method, Slice!(const(Variant)) args); } I think override + final is messing up the C++ mangling. C++: ?CallMethod@Component@ep@@UEAA?AUVariant@2@U?$BaseString@D@2@U?$Slice@$$CBUVariant@ep@@@2@@Z D: ?CallMethod@Component@ep@@QEAA?AUVariant@2@U?$BaseString@D@2@U?$Slice@UVariant@ep@@@2@@Z 'U' is a 'Q', and C++ has a bonus '$$CB'
Comment #1 by turkeyman — 2016-01-26T04:13:47Z
MSVC 2015 - Win64
Comment #2 by bugzilla — 2016-01-26T06:07:49Z
I need a complete example, i.e. the example must be standalone. String, Variant and Slice are not defined.
Comment #3 by dfj1esp02 — 2016-01-26T10:31:16Z
Looks like 'U' is virtual, 'Q' is final, '$$CB' is const in Slice<const Variant>.
Comment #4 by turkeyman — 2016-01-28T02:22:56Z
(In reply to Walter Bright from comment #2) > I need a complete example, i.e. the example must be standalone. String, > Variant and Slice are not defined. I define them as empty structs when testing. extern(C++) struct Slice(T) {} extern(C++) struct String {} extern(C++) struct Variant {}
Comment #5 by iamthewilsonator — 2019-06-10T04:49:46Z
god bolt MSVC v19.20: template<typename T> struct Slice {}; struct String {}; struct Variant {}; void foo(); class IComponent { virtual Variant CallMethod(String method, Slice<const Variant> args) = 0; }; class Component : public IComponent { public: Variant CallMethod(String method, Slice<const Variant> args) override final { foo(); Variant v; return v; } }; LDC beta: extern(C++) interface IComponent { Variant CallMethod(String method, Slice!(const(Variant)) args); } extern (C++) class Component : IComponent { final override Variant CallMethod(String method, Slice!(const(Variant)) args); pragma(msg, CallMethod.mangleof); } extern(C++) struct Slice(T) {} extern(C++) struct String {} extern(C++) struct Variant {} both give //?CallMethod@Component@@UEAA?AUVariant@@UString@@U?$Slice@$$CBUVariant@@@@@Z