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?

Also, is going out of array bounds well defined behavior in D even with boundscheck off? And any links to docs on UB in D?

Reply via email to