On Monday, 28 July 2014 at 15:20:44 UTC, Ola Fosheim Grøstad wrote:
If asserts were used as optimization constraints

all available code is fair game as optimisation constraints. What you are asking for is a special case for `assert` such that the optimiser is blind to it.

bool foo(int a)
{
    //let's handwrite a simple assert
    if(a >= 0)
    {
        exit(EXIT_FAILURE);
    }
    //and then do something.
    return a < 0;
}

Of course the compiler is free to rewrite that as

bool foo(int a)
{
    if(a >= 0)
    {
        exit(EXIT_FAILURE);
    }
    return true;
}

Why should the situation be different if I use the builtin `assert` instead?

Reply via email to