[Issue 19179] New: extern(C++) small-struct by-val uses wrong ABI
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 19 18:51:51 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19179
Issue ID: 19179
Summary: extern(C++) small-struct by-val uses wrong ABI
Product: D
Version: D2
Hardware: All
OS: Windows
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
test.d
------
import core.stdc.stdio;
extern(C++) struct SmallStruct { int x = 10, y = 20; }
SmallStruct test_small(SmallStruct s)
{
printf("%d %d\n", s.x, s.y); // prints: invalid memory
return s;
}
void test_small_noret(SmallStruct s)
{
printf("%d %d\n", s.x, s.y); // prints: 10 20
}
test.cpp
--------
struct SmallStruct { int x = 10, y = 20; };
SmallStruct test_small(SmallStruct);
void test_small_noret(SmallStruct);
void main()
{
test_small(SmallStruct());
test_small_noret(SmallStruct());
}
Tested with VS2015 - x86 and x64
Note: if you add one more `int` to the struct, this code works as expected.
--
More information about the Digitalmars-d-bugs
mailing list