www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2547] New: Array Ops should check length, at least when bounds checking is on

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

           Summary: Array Ops should check length, at least when bounds
                    checking is on
           Product: D
           Version: 2.022
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com


import std.stdio;

void main() {
    double[] foo = [1.0,2,3,4,5].dup;
    double[] bar = [6.0,7,8,9,10].dup;

    double[] baz = new double[1];
    baz[] = foo[] + bar[];
    writeln(baz);  // Prints [7].

    double[] waldo = new double[10];  // Should be all Nans.
    waldo[] = foo[] + bar[];
    writeln(waldo);  // Prints [7 9 11 13 15 0 0 0 7 9].

    double[] stuff = new double[10];
    stuff[] = foo[] + waldo[];
    writeln(stuff);  // Prints [8 11 14 17 20 0 0 0 8 11].
}
The array ops should either automatically change the lengths of baz[] and
waldo[] to match foo[] and bar[] (both in release and debug mode), or throw a
RangeError when bounds checking is enabled.  

In the last example, adding two arrays of different lengths either should not
be allowed and should throw a RangeError when bounds checking is enabled, or
should have reasonably well-defined behavior instead of the seemingly arbitrary
behavior exhibited.


-- 
Dec 30 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2547


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-08-09 00:05:25 PDT ---
*** Issue 4599 has been marked as a duplicate of this issue. ***

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



--- Comment #2 from Simen Kjaeraas <simen.kjaras gmail.com> 2011-02-21 14:36:08
PST ---
*** Issue 3816 has been marked as a duplicate of this issue. ***

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


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #3 from yebblies <yebblies gmail.com> 2012-02-04 17:17:38 EST ---
https://github.com/D-Programming-Language/dmd/pull/693

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



--- Comment #4 from github-bugzilla puremagic.com 2012-07-20 23:37:16 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9c80b3ce49a77f960674ff38df492ec7413376e1
Issue 2547 - Array Ops should check length, at least when bounds checking is on

When array bounds checking is enabled, turn

`arrayOp(a, b, ...)`

into

```
auto tmpa = a, tmpb = b, tmpc = c;
assert(tmpa.length == tmpb.length && tmpa.length == tmpc.length && ..., "length
mismatch for <array op name>");
arrayOp(tmpa, tmpb, tmpc, ...)
```

https://github.com/D-Programming-Language/dmd/commit/34b0f7eba7ada6c39aafc8d19eee3887fa84bf3e
Merge pull request #693 from yebblies/issue2547

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

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



--- Comment #5 from github-bugzilla puremagic.com 2012-07-21 00:07:04 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b6ed591f117f6ac150089585c6965c14b5c5b43c
Revert "Merge pull request #693 from yebblies/issue2547"

This reverts commit 34b0f7eba7ada6c39aafc8d19eee3887fa84bf3e, reversing
changes made to 162cf303c5e70bbb7b0a397b847e0b76c923ddd9.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rride.a gmail.com


--- Comment #6 from Don <clugdbug yahoo.com.au> 2013-06-28 02:31:59 PDT ---
*** Issue 10384 has been marked as a duplicate of this issue. ***

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