Bug 5148 – Incorrect C++ mangling of multiple const char* parameters

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2010-11-01T07:35:00Z
Last change time
2010-11-18T20:07:33Z
Assigned to
nobody
Creator
doob

Attachments

IDFilenameSummaryContent-TypeSize
806cppmangle-fix.diffFix for bug 5148text/plain615
807cppmangle-fix.diffFix for bug 5148 and some other fixes.text/plain3708

Comments

Comment #0 by doob — 2010-11-01T07:35:25Z
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 by luk.wrzosek — 2010-11-03T22:03:52Z
See bug 4059 for patch.
Comment #2 by bugzilla — 2010-11-10T01:23:36Z
The patch for 4059 does not work for this one.
Comment #3 by luk.wrzosek — 2010-11-11T12:52:29Z
Created attachment 806 Fix for bug 5148
Comment #4 by ibuclaw — 2010-11-11T16:26:28Z
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 by ibuclaw — 2010-11-12T00:30:29Z
Apparently I didn't test it against the patch against the trunk last night. :~) It seems fine now I've rebuilt it.
Comment #6 by luk.wrzosek — 2010-11-12T09:23:30Z
Created attachment 807 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 by bugzilla — 2010-11-18T20:07:33Z