On 7/30/14, 4:29 PM, Artur Skawina via Digitalmars-d wrote:
On 07/31/14 01:14, Andrei Alexandrescu via Digitalmars-d wrote:
On 7/30/14, 3:41 PM, David Nadlinger wrote:
On Wednesday, 30 July 2014 at 22:30:59 UTC, Walter Bright wrote:
On 7/30/2014 3:20 PM, Artur Skawina via Digitalmars-d wrote:
    void f(ubyte[] a) @safe { assert(a.length>99); a[88] = a[77]; }

The compiler will insert array bounds checking for you.

Trying to understand what your position is: In release mode, but with
bounds checking enabled, would the compiler
    a) be allowed to replace this with a RangeError or, say, ud2 or
another halt()-type instruction?
    b) treat any call to f() as undefined behavior?

I think that's a good example. My understanding (I know it wasn't me who was 
asked...): the presence of assert should not influence the introduction of 
bounds checks.

But it would. Special casing just the built-in types would only avoid
the problem for built-in types. User defined types that handle the bounds
checks differently would still be affected (and @unsafe).

I think bounds checking is an intrinsic feature of the language, not something easily configurable. -- Andrei

Reply via email to