March 01, 2017
On Wednesday, 1 March 2017 at 09:19:53 UTC, Christian Köstlin wrote:
> On 01/03/2017 00:09, Joseph Rushton Wakeling wrote:
>> if (!__ctfe) assert(false);
>> 
>> ... might be the best option.  That shouldn't be compiled out even in -release builds.
> thats a nice idea! is this happening because of assert(false) being always part of release builds (as mentioned here: https://dlang.org/spec/contracts.html#assert_contracts) or because the if would have no instructions anymore if this is removed.

Yes assert(false) or assert(0) is a special case according to the specification. At least in the DMD implementation it is not removed for -release. If reached it throws an "object.Error@(0): assert(0) or HLT instruction" instead of core.exception.AssertError
March 01, 2017
On Wednesday, March 01, 2017 17:02:37 Dukc via Digitalmars-d-learn wrote:
> On Wednesday, 1 March 2017 at 16:43:41 UTC, Jonathan M Davis
>
> wrote:
> > Assert is for program invariants. If the condition is true, your program is outright broken.
>
> Error: He meant that if the condition is FALSE, the program is faulty.

LOL. True. Sorry about that. Invariants must be true, not false. I should have caught that.

- Jonathan M Davis

1 2
Next ›   Last »