[Issue 13276] New: No overlap or length equality test in compiler generated array operations
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Aug 10 04:28:36 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13276
Issue ID: 13276
Summary: No overlap or length equality test in compiler
generated array operations
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: verylonglogin.reg at gmail.com
Compiler generated array operations truncates second (and third if any) slice
length to the first slice length and has no overlap check.
This code should NOT run fine:
---
void main()
{
alias T = short;
T[] a2 = new T[2];
T[] a3 = (new T[3])[] = 1;
T[] b2 = new T[2];
T[] b3 = new T[3];
// a2[] += a3[]; // ok, throws as runtime function called
// a3[] -= a2[]; // ok, throws
// b3[] = a2[] - a3[]; // ok, throws
// b3[] = a3[] - a2[]; // ok, throws
// Should throw:
// (same for '*', '/', '^', '&', and '|')
a2[] -= a3[];
a2[] -= a2[];
b2[] = a2[] - a3[];
b2[] = a3[] - a2[];
}
---
--
More information about the Digitalmars-d-bugs
mailing list