| 1 |
// EXTRA_CPP_SOURCES: cpp19179.cpp |
| 2 |
|
| 3 |
// https://issues.dlang.org/show_bug.cgi?id=19179 |
| 4 |
|
| 5 |
import core.stdc.stdio; |
| 6 |
|
| 7 |
extern(C++) struct SmallStruct { int x = 10, y = 20; } |
| 8 |
|
| 9 |
extern (C++) |
| 10 |
SmallStruct test_small(SmallStruct s) |
| 11 |
{ |
| 12 |
printf("%d %d\n", s.x, s.y); // prints: invalid memory |
| 13 |
assert(s.x == 10); |
| 14 |
assert(s.y == 20); |
| 15 |
return s; |
| 16 |
} |
| 17 |
|
| 18 |
extern (C++) |
| 19 |
void test_small_noret(SmallStruct s) |
| 20 |
{ |
| 21 |
printf("%d %d\n", s.x, s.y); // prints: 10 20 |
| 22 |
assert(s.x == 10); |
| 23 |
assert(s.y == 20); |
| 24 |
} |
| 25 |
|
| 26 |
extern (C++) void cppmain(); |
| 27 |
|
| 28 |
int main() |
| 29 |
{ |
| 30 |
cppmain(); |
| 31 |
return 0; |
| 32 |
} |