checkedint call removal

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 28 08:52:21 PDT 2014


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?


More information about the Digitalmars-d mailing list