www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 291] New: assertion

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=291

           Summary: assertion
           Product: D
           Version: 0.164
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: lio lunesu.com


void main()
{
        real a;
//      printf("%Lf",a);        // prints "nan"
        assert(a==0.0);         // unexpected PASS!
}

DMD v0.164; assertion correctly fails for double and float, but passes for real
(really). Uncommenting the printf does not change the behavior. Compiled with
-debug -g:

image00400000!_Dmain:
00402010 c80c0000         enter   0xc,0x0
00402014 db2d80004100     fld     tbyte ptr [000000000081209a]
0040201a db7df4           fstp    tbyte ptr [rbp-0xc]
0040201d db6df4           fld     tbyte ptr [rbp-0xc]
00402020 d9ee             fldz
00402022 dae9             fucompp
00402024 dfe0             fstsw
00402026 9e               sahf
00402027 740a jz image00400000!_Dmain+0x23 (00402033)
00402029 b805000000       mov     eax,0x5
0040202e e805000000 call image00400000!assert_1t (00402038)
00402033 31c0             xor     eax,eax
00402035 c9               leave
00402036 c3               ret

The following code is generated when using "double" instead of "real". The
assertion correctly fails.

image00400000!_Dmain:
00402010 c8080000 enter  0x8,0x0
00402014 dd0580004100 fld qword ptr [image00400000!_xt_z+0x10 (00410080)]
0040201a dd5df8  fstp    qword ptr [ebp-0x8]
0040201d 8b45fc  mov     eax,[ebp-0x4]
00402020 01c0    add     eax,eax
00402022 0b45f8  or      eax,[ebp-0x8]
00402025 740a    jz    image00400000!_Dmain+0x21 (00402031)
00402027 b805000000 mov  eax,0x5
0040202c e807000000 call image00400000!assert_1t (00402038)
00402031 31c0    xor     eax,eax
00402033 c9      leave
00402034 c3      ret


-- 
Aug 17 2006
next sibling parent Lionello Lunesu <lio lunesu.remove.com> writes:
Sorry for the bad subject :( I've already changed the subject in bugzilla.
Aug 17 2006
prev sibling next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-08-17:
 http://d.puremagic.com/issues/show_bug.cgi?id=291
 void main()
 {
         real a;
 //      printf("%Lf",a);        // prints "nan"
         assert(a==0.0);         // unexpected PASS!
 }

 DMD v0.164; assertion correctly fails for double and float, but passes for real
 (really).
Added to DStress as http://dstress.kuehne.cn/run/f/float_28_A.d http://dstress.kuehne.cn/run/f/float_28_B.d http://dstress.kuehne.cn/run/f/float_28_C.d http://dstress.kuehne.cn/run/f/float_28_D.d http://dstress.kuehne.cn/run/d/double_31_A.d http://dstress.kuehne.cn/run/d/double_31_B.d http://dstress.kuehne.cn/run/d/double_31_C.d http://dstress.kuehne.cn/run/d/double_31_D.d http://dstress.kuehne.cn/run/r/real_27_A.d http://dstress.kuehne.cn/run/r/real_27_B.d http://dstress.kuehne.cn/run/r/real_27_C.d http://dstress.kuehne.cn/run/r/real_27_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE5QoWLK5blCcjpWoRApCHAJ9V2EGQmZ56yTgm7jmDNkyJ8BXT9gCfWF/u zOWzuZPjRlB/zKkVah37dzs= =7/nH -----END PGP SIGNATURE-----
Aug 18 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=291


thomas-dloop kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au





*** Bug 365 has been marked as a duplicate of this bug. ***


-- 
Oct 02 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=291


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
            Summary|uninitialized 'real' passes |Bad code generation for real
                   |for 0.0                     |== 0, !=0 (incorrect for
                   |                            |NaN)





Changed name and severity of this bug, since it applies to !=0 as well as ==.
(Taken from bug 365):

void main()
{
     real x = real.nan;
     assert( x!=0 );              // fails
     if (x==0) assert(0);         // fails
}

It looks to me as though there's a JPE instruction missing, to cover the NaN
case. I'm no longer confident that this is a regression.

ie, should be
jp image00400000!_Dmain+0x23 (00402033)
jz image00400000!_Dmain+0x23 (00402033)
---------------------


-- 
Oct 02 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=291


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 0.168


-- 
Oct 04 2006