On Thursday, 31 July 2014 at 20:24:09 UTC, Walter Bright wrote:
On 7/31/2014 4:36 AM, bearophile wrote:
int max(in int x, in int y) {
    assume(x > y);
    return (x > y) ? x : y;
}

The optimizer is free to replace that code with this, even in debug builds:

int max(in int x, in int y) {
    return x;
}

That implies that the behavior is undefined if the assumption is false. A compiler is free to add checks for undefined behavior (you yourself are a huge proponent of this) and people would (very reasonably for a quality implementation) expect that the assumption is checked. Hence, it will behave like assert.

You are asking bearophile to give an example, he gives an example, and you redefine his definition?!

The whole point of assume is that it is unchecked and unsafe.

Reply via email to