Bug 14971 – array.length -= x; should be checked for underflow when compiling without -release

Status
NEW
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-08-27T15:03:27Z
Last change time
2024-12-07T13:35:42Z
Assigned to
No Owner
Creator
Collin Reeser
Moved to GitHub: dmd#17310 →

Comments

Comment #0 by collin.reeser — 2015-08-27T15:03:27Z
For exactly the same reason that the index-out-of-bounds runtime checks are useful for debugging purposes when compiling without the -release flag, decrements on the array .length attribute should be checked during runtime for underflow. As it is now: int main() { int[] a = []; a.length--; return 0; } Will yield: core.exception.OutOfMemoryError@(0) This should instead be an error message along the lines of the index-out-of-bounds exception that indicates what the problem actually is. This is related to Issue 3933 from 2010 (there's still no line number on the error, which goes a long way to making this issue less important).
Comment #1 by robert.schadek — 2024-12-07T13:35:42Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17310 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB