Thread overview
[Issue 291] New: assertion
Aug 17, 2006
d-bugmail
uninitialized 'real' passes for 0.0
Aug 17, 2006
Lionello Lunesu
Aug 18, 2006
Thomas Kuehne
[Issue 291] uninitialized 'real' passes for 0.0
Oct 02, 2006
d-bugmail
[Issue 291] Bad code generation for real == 0, !=0 (incorrect for NaN)
Oct 02, 2006
d-bugmail
Oct 05, 2006
d-bugmail
August 17, 2006
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


-- 

August 17, 2006
Sorry for the bad subject :( I've already changed the subject in bugzilla.
August 18, 2006
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



October 02, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=291


thomas-dloop@kuehne.cn changed:

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




------- Comment #2 from thomas-dloop@kuehne.cn  2006-10-02 03:11 -------
*** Bug 365 has been marked as a duplicate of this bug. ***


-- 

October 02, 2006
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)




------- Comment #3 from clugdbug@yahoo.com.au  2006-10-02 06:24 -------
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)
---------------------


-- 

October 05, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=291


bugzilla@digitalmars.com changed:

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




------- Comment #4 from bugzilla@digitalmars.com  2006-10-04 20:17 -------
Fixed DMD 0.168


--