Bug 20716 – Wrong code/ABI for extern(C++) interface method that returns non-POD

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-04-01T02:34:43Z
Last change time
2020-11-09T01:15:32Z
Keywords
backend, C++, pull, wrong-code
Assigned to
No Owner
Creator
Илья Ярошенко

Comments

Comment #0 by ilyayaroshenko — 2020-04-01T02:34:43Z
// OS: Linux, macOS extern(C++, "foo"): struct S { void* s; ~this() {} // or this(this) {} } interface I { S x(); } final class C : I { long l = 3; S x() { assert(l == 3); //fails return S.init; } } extern(D) void main() { auto s = new C().I.x; }
Comment #1 by ilyayaroshenko — 2020-04-01T02:35:29Z
works well with LDC
Comment #2 by bugzilla — 2020-09-07T05:56:56Z
Curiously, this works on Windows.
Comment #3 by bugzilla — 2020-09-07T08:27:09Z
The problem here is the "adjustor thunk" generated does not take into account the size of the hidden pointer parameter, and winds up adjusting the hidden pointer rather than the `this` pointer.
Comment #4 by dlang-bot — 2020-09-07T09:28:04Z
@WalterBright created dlang/dmd pull request #11703 "fix Issue 20716 - Wrong code/ABI for extern(C++) interface method tha…" fixing this issue: - fix Issue 20716 - Wrong code/ABI for extern(C++) interface method that returns non-POD https://github.com/dlang/dmd/pull/11703
Comment #5 by dlang-bot — 2020-11-09T01:15:32Z
dlang/dmd pull request #11703 "fix Issue 20716 - Wrong code/ABI for extern(C++) interface method tha…" was merged into master: - 9ad79f65edba40925c4f4d92c5603fb5711cd85a by Walter Bright: fix Issue 20716 - Wrong code/ABI for extern(C++) interface method that returns non-POD https://github.com/dlang/dmd/pull/11703