www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - assert fails to fail

reply Derek Parnell <derek psych.ward> writes:
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
next sibling parent "Walter" <newshound digitalmars.com> writes:
Sorry about that. It'll get fixed next update.
May 31 2005
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.this-is.spam.cn> writes:
-----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