assume, assert, enforce, @safe

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 14:25:19 PDT 2014


On 7/31/2014 1:33 PM, David Nadlinger wrote:
> I've had the questionable pleasure of tracking down a couple of related issues
> in LLVM and the LDC codegen, so please take my word for it: Requiring any
> particular behavior such as halting in a case that can be assumed to be
> unreachable is at odds with how the term "unreachable" is used in the wild – at
> least in projects like GCC and LLVM.

For example:

  int foo() {
    while (...) {
        ...
    }
    assert(0);
  }

the compiler needn't issue an error at the end "no return value for foo()" 
because it can assume it never got there.

I'll rewrite that bit in the spec as it is clearly causing confusion.



More information about the Digitalmars-d mailing list