Bug 18954 – extern(C++) ICE when `cppmangle` is used
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2018-06-08T04:19:59Z
Last change time
2018-07-10T18:38:32Z
Keywords
C++, industry
Assigned to
No Owner
Creator
Manu
Comments
Comment #0 by turkeyman — 2018-06-08T04:19:59Z
test.d:
--------------------------------------------------------------
extern (C++, std)
{
extern (C++, class) struct allocator(T)
{
}
extern (C++, struct) struct char_traits(Char)
{
}
extern (C++, class) struct basic_string(T, Traits, Alloc)
{
}
alias string = basic_string!(char, char_traits!char, allocator!char);
}
extern (C++) void test(ref const(std.string) str) {}
--------------------------------------------------------------
The problem is instantiating basic_string!(...)
`basic_string` is mangled as a class, but char_traits is mangled as a struct.
When instantiating basic_string with char_traits as an argument, it triggers an assert in a weird bit of code insisting that the mangle types be the same (but they're not)
Comment #1 by turkeyman — 2018-06-08T04:21:02Z
I don't understand the intent of the code that asserts.
Walter might want to have a look, since he probably understands what the logic is intended to do?
Comment #2 by slavo5150 — 2018-07-06T13:06:24Z
I cannot reproduce this on Linux or Windows with 2.081.
Comment #3 by turkeyman — 2018-07-06T17:37:44Z
I'm pretty sure nobody attempted to fix it...?
Comment #4 by slavo5150 — 2018-07-06T20:36:24Z
I attempted to fix it, but couldn't reproduce it, so I don't know what needs to be fixed.
Comment #5 by turkeyman — 2018-07-10T18:22:44Z
I just tried to repro with 2.081.1b, this issue as logged above seems to be resolved.
This variant persists though:
test.d:
--------------------------------------------------------------
extern (C++, std)
{
extern (C++, class) struct allocator(T)
{
}
struct char_traits(Char)
{
}
extern (C++, class) struct basic_string(T, Traits, Alloc)
{
}
alias string = basic_string!(char, char_traits!char, allocator!char);
}
extern (C++) void test(ref const(std.string) str) {}
--------------------------------------------------------------
I just removed the explicit `extern(C++, struct)` from the struct. It's declared as a struct, no need to override a struct as struct!
In this code, it gets mangled as a class instead of as a struct, which is incorrect.
This is only relevant on windows, this issue doesn't affect linux (posix mangling doesn't distinguish class/struct).
Comment #6 by turkeyman — 2018-07-10T18:38:32Z
That still-broken variant is logged as another bug:
https://issues.dlang.org/show_bug.cgi?id=18955
This particular one seems to have been fixed... perhaps by accident? O_o
I can't find a recent patch that looks like it should have fixed this.
Marking as resolved...