Are contracts intended for verifying @safety;

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 7 12:42:26 PST 2016


On 11/07/2016 09:16 PM, Somebody wrote:
> Can the version switch be used to detect noboundscheck?

Apparently, yes: `version (D_NoBoundsChecks)`.

http://dlang.org/spec/version.html#predefined-versions

> I was thinking
> that if, it could be used to make an overload of enforce that acts just
> like in your example, but is taken off with bounds checking. Then it
> would not violate safety any more than arrays do, yet could be compiled
> to as efficient a release build as the contract version, if needed.

You're probably aware of it, but just to be sure: Note that 
-noboundscheck (or -boundscheck=off) absolutely breaks safety.


More information about the Digitalmars-d-learn mailing list