[Issue 1294] New: referencing fields in static arrays of structs passed as arguments generates invalid code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 27 07:14:17 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1294
Summary: referencing fields in static arrays of structs passed as
arguments generates invalid code
Product: D
Version: 1.001
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: major
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: thecybershadow at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list