digitalmars.D.bugs - Struct bug
- Nick <Nick_member pathlink.com> Jan 28 2005
- =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= Jan 29 2005
Here is a bug I encountered a while ago, but did not have the time to narrow
down and report until now:
# import std.stdio;
#
# struct MyStruct
# {
# int i;
#
# void display()
# {
# writefln("getting i=", i);
# }
#
# void someFunc()
# {
# // We never call this function
# void bug(MyStruct[] array)
# {
# // Comment out this line and the bug goes away
# array[0].i = i+1;
# }
#
# writefln("i=", i);
# display();
# writefln("i=", i);
# }
# }
#
# void main()
# {
# MyStruct m;
# m.i = 10;
# m.someFunc();
# }
When I run this I get (on linux, dmd 0.111)
i=10
getting i=-1073754812
i=10
The middle (erroneous) value seems to vary somewhat randomly.
Nick
Jan 28 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Added to DStress as http://dstress.kuehne.cn/run/bug_20050128_A.d http://dstress.kuehne.cn/run/bug_20050128_B.d Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (MingW32) iD8DBQFB+1en3w+/yD4P9tIRAtovAJ9XeTQCx5ekwRUA1G8lWMFU1hKmOgCgl/vM DkP5T652X2APKK+5Zr8VyLc= =nYJU -----END PGP SIGNATURE-----
Jan 29 2005








=?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?=