D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19161 - Wrong mangle for C++ classes
Summary: Wrong mangle for C++ classes
Status: RESOLVED DUPLICATE of issue 18896
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords: C++, mangling
Depends on:
Blocks:
 
Reported: 2018-08-12 08:56 UTC by Илья Ярошенко
Modified: 2020-02-19 05:33 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Илья Ярошенко 2018-08-12 08:56:15 UTC
extern(C++)
{

class Foo
{

}

void foo(Foo);

pragma(msg, foo.mangleof);

}


mangled to:
void __cdecl foo(class Foo * __ptr64)

expected (because of common C++ & STL practice):
void __cdecl foo(class Foo & __ptr64)
Comment 1 Nicholas Wilson 2018-08-21 05:51:52 UTC
Does 

extern(C++,class)
struct Foo
{

}

extern(C++) void foo(ref Foo);

pragma(msg, foo.mangleof);

work?
Comment 2 Илья Ярошенко 2019-04-12 15:14:08 UTC
Yes, but this workaround breaks a lot of API logic on the D side.
Comment 3 kinke 2019-04-12 20:20:01 UTC
There's no clear right or wrong here, and the proposed change would probably break a lot of code. E.g., all DMD C++ headers would need to be adapted. Additionally, a D class reference can safely be assumed to be null, while you normally don't expect null for a C++ reference. => WONTFIX IMO
Comment 4 Mathias LANG 2020-02-19 05:33:48 UTC
Duplicate of 18896 which has a bit more specific title.

*** This issue has been marked as a duplicate of issue 18896 ***