D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5148 - Incorrect C++ mangling of multiple const char* parameters
Summary: Incorrect C++ mangling of multiple const char* parameters
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 blocker
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-01 07:35 UTC by Jacob Carlborg
Modified: 2010-11-18 20:07 UTC (History)
3 users (show)

See Also:


Attachments
Fix for bug 5148 (615 bytes, patch)
2010-11-11 12:52 UTC, Lukasz Wrzosek
Details | Diff
Fix for bug 5148 and some other fixes. (3.62 KB, patch)
2010-11-12 09:23 UTC, Lukasz Wrzosek
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2010-11-01 07:35:25 UTC
DMD incorrectly mangles the following function:

extern (C++) void error (const char*, const char*) {}

DMD mangling: __Z5errorPKcS_
GCC mangling: __Z5errorPKcS0_

It has to be at least two parameters, not the first parameter and any of the other parameters have to be const char*.

I don't know if this is the same bug as 4059 but that one doesn't mention const. This is also a blocker for DDMD on Posix.
Comment 1 Lukasz Wrzosek 2010-11-03 22:03:52 UTC
See bug 4059 for patch.
Comment 2 Walter Bright 2010-11-10 01:23:36 UTC
The patch for 4059 does not work for this one.
Comment 3 Lukasz Wrzosek 2010-11-11 12:52:29 UTC
Created attachment 806 [details]
Fix for bug 5148
Comment 4 Iain Buclaw 2010-11-11 16:26:28 UTC
That's not really a proper fix.

Yes, it works for this original example in this report, however it doesn't pass this test:

extern (C++) void bug5148a(char*,       char*,       char*,       char*);
extern (C++) void bug5148b(char*,       char*,       char*,       const char*);
extern (C++) void bug5148c(char*,       char*,       const char*, char*);
extern (C++) void bug5148d(char*,       char*,       const char*, const char*);
extern (C++) void bug5148e(char*,       const char*, char*,       char*);
extern (C++) void bug5148f(char*,       const char*, char*,       const char*);
extern (C++) void bug5148g(char*,       const char*, const char*, char*);
extern (C++) void bug5148h(char*,       const char*, const char*, const char*);
extern (C++) void bug5148i(const char*, char*,       char*,       char*);
extern (C++) void bug5148j(const char*, char*,       char*,       const char*);
extern (C++) void bug5148k(const char*, char*,       const char*, char*);
extern (C++) void bug5148l(const char*, char*,       const char*, const char*);
extern (C++) void bug5148m(const char*, const char*, char*,       char*);
extern (C++) void bug5148n(const char*, const char*, char*,       const char*);
extern (C++) void bug5148o(const char*, const char*, const char*, char*);
extern (C++) void bug5148p(const char*, const char*, const char*, const char*);


Regards
Comment 5 Iain Buclaw 2010-11-12 00:30:29 UTC
Apparently I didn't test it against the patch against the trunk last night. :~)
It seems fine now I've rebuilt it.
Comment 6 Lukasz Wrzosek 2010-11-12 09:23:30 UTC
Created attachment 807 [details]
Fix for bug 5148 and some other fixes.

This patch fixes also some other issues that I think weren't reported up to now.
In gcc c++ functions with const arguments passed by value are mangled like not const:
void Test(const int, const int) -> _Z4Testii
void Test(const char, const char) -> _Z4Testcc

struct MyStrutType { };
void Test(const MyStructType, const MyStructType) -> _Z4Test12MyStructTypeS_

enum MyEnumType { };
void Test(const MyEnumType, const MyEnumType) -> _Z4Test10MyEnumTypeS_

Without this patch dmd generates const versions.
Comment 7 Walter Bright 2010-11-18 20:07:33 UTC
http://www.dsource.org/projects/dmd/changeset/762