No compile time bounds checking for static arrays?

Tejas notrealemail at gmail.com
Wed Aug 11 06:29:40 UTC 2021


```d
import std;
void main()
{
     int[40] staticA;
     auto c = staticA[0..50];//mistake
}```
results in:

```d
core.exception.RangeError at onlineapp.d(5): Range violation
----------------
??:? _d_arrayboundsp [0x55db29a0b645]
./onlineapp.d:5 _Dmain [0x55db29a0ae8c]
```

Is there a way to make this check compile time?


More information about the Digitalmars-d-learn mailing list