Bug 1294 – referencing fields in static arrays of structs passed as arguments generates invalid code
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-06-27T09:14:00Z
Last change time
2014-02-16T15:26:09Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2007-06-27T09:14:15Z
import std.stdio;
struct TestStruct
{
int dummy0;
int dummy1;
int dummy2;
}
void func(TestStruct[2] testarg)
{
writefln(&testarg); // outputs m's address, correct
writefln(&testarg[0]); // outputs m's address (same as above), correct
writefln(&testarg[0].dummy0); // outputs m's address (same as above), correct
writefln(&testarg[0].dummy1); // outputs the contents of the stack, one DWORD higher than the "testarg" argument (which holds the address to m) - the saved stack pointer?
writefln(&testarg[0].dummy2); // outputs the contents of the stack, two DWORDs higher than the "testarg" argument - the return address
}
TestStruct m[2];
void main()
{
writefln(&m); // for reference
func(m);
}
This goes back from at least 1.001 and up to 1.017 and 2.000.
It works on GDC.