digitalmars.D.bugs - assert fails to fail
- Derek Parnell (40/40) May 30 2005 Given the program below ...
- Walter (1/1) May 31 2005 Sorry about that. It'll get fixed next update.
- Thomas Kuehne (14/50) Jun 01 2005 -----BEGIN PGP SIGNED MESSAGE-----
Given the program below ... [test.d] <code> debug(1) import std.stdio; dchar[] SomeFunc( dchar[] pText, out int pStopPosn) { if (pText.length == 0) pStopPosn = 0; else pStopPosn = -1; debug(1) writefln("DEBUG: using '%s' we get %d", pText, pStopPosn); return pText.dup; } int main(char[][] pArgs) { int sp; SomeFunc("123", sp); debug(1) writefln("DEBUG: got %d", sp); assert(sp == -1); SomeFunc("", sp); debug(1) writefln("DEBUG: got %d", sp); assert(sp == -1); return 0; } </code> and compiled with "dmd test.d" version 0.125, the last assert() fails to mistake. You can compile with -debug to take a look at the returned data and this shows that it is being set correctly, its just that assert() doesn't seem to see the most recent value. I chopped down this example from a 3,600 line program so its taken a long while to isolate the offending conditions. -- Derek Melbourne, Australia 31/05/2005 11:09:36 AM
May 30 2005
Sorry about that. It'll get fixed next update.
May 31 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Derek Parnell schrieb am Tue, 31 May 2005 11:19:42 +1000:Given the program below ... [test.d] <code> debug(1) import std.stdio; dchar[] SomeFunc( dchar[] pText, out int pStopPosn) { if (pText.length == 0) pStopPosn = 0; else pStopPosn = -1; debug(1) writefln("DEBUG: using '%s' we get %d", pText, pStopPosn); return pText.dup; } int main(char[][] pArgs) { int sp; SomeFunc("123", sp); debug(1) writefln("DEBUG: got %d", sp); assert(sp == -1); SomeFunc("", sp); debug(1) writefln("DEBUG: got %d", sp); assert(sp == -1); return 0; } </code> and compiled with "dmd test.d" version 0.125, the last assert() fails to mistake. You can compile with -debug to take a look at the returned data and this shows that it is being set correctly, its just that assert() doesn't seem to see the most recent value. I chopped down this example from a 3,600 line program so its taken a long while to isolate the offending conditions.Added to DStress as http://dstress.kuehne.cn/norun/a/assert_10_A.d http://dstress.kuehne.cn/norun/a/assert_10_B.d http://dstress.kuehne.cn/norun/a/assert_10_C.d http://dstress.kuehne.cn/norun/a/assert_10_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCnixn3w+/yD4P9tIRAocIAJ9IdbhBdGvodwr0ZzcCsKkKjGKnEACeOamV 0JBF7QyrAOSMGjs77jmiJqY= =IuJ8 -----END PGP SIGNATURE-----
Jun 01 2005