[Issue 2547] Array Ops should check length, at least when bounds checking is on

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 17 23:43:00 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=2547


Denis Shelomovskij <verylonglogin.reg at gmail.com> changed:

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


--- Comment #10 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-11-18 11:42:53 MSK ---
I was wrong. It's not fixed. The pull just fixed druntime but dmd sometimes
generate vector functions itself like `_arraySliceSliceSubass_i` for `a[] -=
b[]` and doesn't check arrays for being conformable. E.g. this program does not
throw any errors:
---
void main()
{
    int[] a = new int[3];
    int[] b = new int[7]; b[] = 1;

//  a[] += b[]; // ok, calls _arraySliceSliceAddass_i and throws
//  a[] *= b[]; // ok, calls _arraySliceSliceMulass_i and throws

    a[] -= b[];
    a[] /= b[]; 

    a[] &= b[];
    a[] |= b[];
    a[] ^= b[];
}
---

To fix this we should make `enforce*ArraysConformable` API from `rt.util.array`
public and dmd should call these functions in generated vector functions just
like druntime do.

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


More information about the Digitalmars-d-bugs mailing list