Walter Bright:

I'd like to see what you are saying is different in a real example.

(The problem is that your have defined your own idea, so what I can show you will look meaningless or not comformant to your own definition. So this discussion is going nowhere. And my original topic drowns in this assume/assert debate that is off-topic.)


In the case of assume:


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;
}



In the case of assert:

int max(in int x, in int y) {
    assert(x > y);
    return (x > y) ? x : y;
}


In debug builds gets rewritten as:

int max(in int x, in int y) {
    if (x <= y)
        throw new AssertError("...");
    return x;
}


And in release builds gets rewritten as:

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


Bye,
bearophile

Reply via email to