[Issue 13228] Value range analysis for the length of slices
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 30 12:01:30 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13228
--- Comment #1 from bearophile_hugs at eml.cc ---
Beside allowing safe implicit casts as shown above, this feature is also able
to catch slice-related bugs at compile time, like in this code:
int x = 11;
void main() {
int[100] a;
const b = a[5 .. 5 + x];
int[10] c = b;
}
That in dmd 2.066beta5 compiles without errors, and throws an error at
run-time:
object.Error@(0): Array lengths don't match for copy: 11 != 10
--
More information about the Digitalmars-d-bugs
mailing list