www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3687] New: Array operation "slice times scalar" tramples over memory

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

           Summary: Array operation "slice times scalar" tramples over
                    memory
           Product: D
           Version: 1.053
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: eriatarka84 gmail.com



The following code fails with an assertion failure when it clearly shouldn't:

====================================================

void main()
{
    float[64] array;
    int i = 42;

    auto slice = array[];
    slice[] *= 2f;

    assert(i == 42);
}

====================================================

Array bounds checking doesn't catch this. I presume that the code in the
runtime to execute this array operation is buggy.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3687




Created an attachment (id=548)
patch against druntime to fix the problem

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




Yes, it is buggy. I've uploaded a patch to fix the routine which does float
array times scalar multiplication, though probably it's a better idea to file
it at druntime directly. I'll crosspost it there.

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




I've realized that the other float array operations of the form "array op=
scalar" suffer from the same problem. Please hold off with applying this patch,
I'll provide a more general one. I hope string mixins are ok to use in
druntime? There's quite a lot of code duplication in these array modules.

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




I submitted the patch to Tango (since that's what I use currently), it was
folded into their copy of the runtime. I would appreciate if someone merged the
changes into druntime to keep them in lockstep. Patch and discussion are here:

http://www.dsource.org/projects/tango/ticket/1831

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 18 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3687




The original test case passes on D2, but here's a test case which fails on both
D1 and D2.
------
void main()
{
    float[66] array;
    array[] = 0;
    array[64] = 42;
    array[65] = 43;
    array[0..64] *= 2f;
    assert(array[65] == 43);
    assert(array[64] == 42);
}
------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 20 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3687




Changes checked into druntime svn 234 and D1 phobos svn 1403.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 21 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3687


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



22:41:36 PST ---
fixed dmd 1.056 and 2.040

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