[Issue 5809] [64 bit] wrong code for *p==0, when widening conversion occurs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 8 22:07:08 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5809


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|feqrel fails assert in      |[64 bit] wrong code for
                   |std.math on x86_64 systems  |*p==0, when widening
                   |                            |conversion occurs
           Severity|normal                      |blocker


--- Comment #5 from Don <clugdbug at yahoo.com.au> 2012-05-08 22:08:29 PDT ---
Original title: feqrel fails assert in std.math on x86_64 systems

Reduced test case shows it is a backend bug.
The common subexpression *px gets extended to int when calculating b. Inside
the assert it is treated as *cast(int *)px, so that it picks up x[1] instead of
just x[0]. It seems to only apply to comparisons with 0.
Subtle and disastrous, raising severity to blocker.

void main()
{
    ushort[2] x = void;
    x[0] = 0;
    x[1] = 0x1234;

    ushort *px =  &x[0];

    uint b = px[0];  // this causes the next line to fail

    assert(px[0] == 0);
 }

It generates
   cmp    dword ptr -010h[RBP],0
should be word ptr, which doesn't exist in 64bit.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list