May 02, 2019 [Issue 19841] New: Wrong ABI for C++ functions taking a struct by value | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19841 Issue ID: 19841 Summary: Wrong ABI for C++ functions taking a struct by value Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: blocker Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: atila.neves@gmail.com Code: ------------------------ extern(C++) { struct Foo { void[32] _; } struct Bar { this(Foo foo); } } void oops() { auto foo = Foo(); auto bar = Bar(foo); } -------------------------- The assembly for oops doesn't even mention the RSI register where the address of `foo` should be passed in (RDI contains the address of where to construct `bar`). It tries to pass `foo` to the `Bar` constructor on the stack. The equivalent C++ code passes `foo` as an address in RSI. Calling the C++ implementation results in segfault. The bug is weirdly present in ldc and gdc as well. -- |
Copyright © 1999-2021 by the D Language Foundation