Bug 8870 – Incorrect values passing struct by value

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-10-22T12:39:00Z
Last change time
2015-06-09T05:11:53Z
Assigned to
nobody
Creator
turkeyman

Comments

Comment #0 by turkeyman — 2012-10-22T12:39:58Z
http://dpaste.dzfl.pl/82f04399 t2 is [5, 6, 5, 6] when compiled with DMD-x64. should be [5, 6, 7, 8]. extern (C) fixes the problem. ---------------------------------------------------- import std.stdio; struct Test { float x = 0; float y = 0; float z = 0; float w = 0; } void main() { Test r1 = Test(1,2,3,4); Test r2 = Test(5,6,7,8); test(r1, r2, false, 1); } void test(Test t1, Test t2, bool someBool, float finalFloat) { // at this point, t2 == { 5, 6, 5, 6 } writeln(t2); }
Comment #1 by github-bugzilla — 2012-10-25T17:18:19Z
Comment #2 by github-bugzilla — 2012-10-25T17:18:30Z