On Sunday, 31 December 2017 at 13:14:10 UTC, aliak wrote:
On Sunday, 31 December 2017 at 01:03:17 UTC, Tony wrote:
For me, front() should throw a pre-defined exception when called on an empty range in order to eliminate undefined behavior. It does take some time to make a check, but D does array bounds checking by default. Ideally the front() check could be turned off somehow ("-boundschecks=off") by the user for those who want maximum speed, but I guess there is no way to do that when using pre-compiled functions in a library.

That sounds like a good idea. Wouldn't the same apply to array bounds checking for precompiled functions though?

Yeah, seems like the standard library must be doing one or the other (bounds checking array indexes or not bounds checking them) all the time, depending on how it was compiled.

Also, is going out of array bounds well-defined behavior in D even with bounds check off?

I'm no expert, but I can't think of how it could be.

And any links to docs on UB in D?

This thread was the first time I have heard it used with regard to D.


Reply via email to