1294 – referencing fields in static arrays of structs passed as arguments generates invalid code

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1294 - referencing fields in static arrays of structs passed as arguments generates invalid code
Summary: referencing fields in static arrays of structs passed as arguments generates ...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 major
Assignee: Walter Bright
URL:
Keywords: wrong-code
Depends on:
Blocks:
Reported: 2007年06月27日 09:14 UTC by Vladimir Panteleev
Modified: 2014年02月16日 15:26 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2007年06月27日 09:14:15 UTC
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.
Comment 1 Walter Bright 2007年07月01日 14:10:06 UTC
Fixed DMD 1.018 and DMD 2.002


AltStyle によって変換されたページ (->オリジナル) /