Ulrik Mikaelsson:

> Isn't the real reason for this that bounds-checking is usually
> completely turned-off in release-builds?

Bounds checking is turned off in release builds mostly because:
1) DMD is not able to infer & remove most bound checks at compile-time as the 
latest Oracle VM are able to do;
2) and because Walter & Co. believe such analysis isn't able to remove most 
bound checks anyway (I have not seen this hypothesis confirmed yet).


> Sounds like something that could noticeably degrade runtime-performance
> for array-intensive code?

The safety net we are talking about is present only at the right bound of a 
slicing syntax (it's not performed in normal array indexing), and it consists 
in a single min(x, $) operation, that's one branch. So it slows down code, but 
only a bit. And in many of such situations you probably need to add a min(x, $) 
manually in the code anyway, so the overhead is limited.

Bye,
bearophile

Reply via email to