[Issue 22198] New: Compile time bounds checking for static arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 11 07:26:26 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22198
Issue ID: 22198
Summary: Compile time bounds checking for static arrays
Product: D
Version: D2
Hardware: Other
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: scienticman at gmail.com
The following code fails to error out at compile time:
void main(){
int[10] a;
auto b = a[0..20];//mistake
}
The error is instead:
core.exception.RangeError at onlineapp.d(3): Range violation
----------------
??:? _d_arrayboundsp [0x555bdc2b6c29]
./onlineapp.d:3 _Dmain [0x555bdc2b6b86]
This can easily be caught at compile time, please do so.
Thank you for your time!
--
More information about the Digitalmars-d-bugs
mailing list