This struct is passed in registers by dmd, while dmc++ (and presumably msvc) returns it on the stack, causing crash. Adding a dtor 'fixes' it. struct Prot { int kind; void *pkg; extern(D) this(int kind) { this.kind = kind; this.pkg = null; } // ~this() // { // } } extern(C++) Prot func(); void main() { auto p = func(); }
https://github.com/D-Programming-Language/dmd/pull/4124
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/69a5745cdb2077936423920cc56c8e5a5934d1d7 Fix Issue 13707 - msvc32 C++ struct return ABI not followed for structs with constructors A constructor should stop a struct from being passed in registers on win32/C++. https://github.com/D-Programming-Language/dmd/commit/452cfcc1f20c505f5844a993c6731839325e5e63 Merge pull request #4124 from yebblies/issue13707 [DDMD] Issue 13707 - msvc32 C++ struct return ABI not followed for structs with constructors
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/69a5745cdb2077936423920cc56c8e5a5934d1d7 Fix Issue 13707 - msvc32 C++ struct return ABI not followed for structs with constructors https://github.com/D-Programming-Language/dmd/commit/452cfcc1f20c505f5844a993c6731839325e5e63 Merge pull request #4124 from yebblies/issue13707