www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8340] New: *= operator breaks long array in x64

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

           Summary: *= operator breaks long array in x64
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: iselix1988+dbugzilla gmail.com



When using *= operator with -1 of constant value for long array element , it
breaks next element value .

See code below:

---
void main(){
    int[] ia = [1,2,3,4,5];
    long[] la = [1,2,3,4,5];

    ia[2] *= -1;
    la[2] *= -1;

    assert(ia == [1,2,-3,4,5]); // OK in x86 and x64
    assert(la == [1,2,-3,4,5]); // OK in x86 but Failed in x64
    // la == [1,2,-3,-5,5] in x64
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 03 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8340


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx



Tested on dmd git HEAD and gdc 4.7 (2.058); the bug only happens on dmd -m64.
Not sure if this is a regression, or if it's a dmd backend bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8340




Hmm, looks like a dmd backend bug: gdc (unoptimized) produces neg (respectively
negl) instructions for negating the array element of ia (resp. la), but dmd
-m64 produces negl (resp. negq) instead.

This produces correct results for la, because dmd actually generates it as a
quad array, whereas ia remains an int array. This is a violation of the D spec
(which states that int==32 bits and long==64 bits; seems like the dmd backend
is wrongly using int==32 bits and long==128 bits (inconsistently).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8340




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/af7b7f098a6e91c34993f43d3afda54e54a96a4e
fix Issue 8340 - *= operator breaks long array in x64

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 09 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8340




Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/74eee15c8ed326f53bed4956e772064a4ee6e246
fix Issue 8340 - *= operator breaks long array in x64

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 09 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8340


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
            Version|D2                          |D1 & D2
         Resolution|                            |FIXED
           Severity|normal                      |major


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