checkedint call removal

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 12:16:13 PDT 2014


On Wed, Jul 30, 2014 at 07:09:41PM +0000, via Digitalmars-d wrote:
> On Wednesday, 30 July 2014 at 18:25:43 UTC, H. S. Teoh via Digitalmars-d
> wrote:
> >If you want the check to always be there, use enforce, not assert.
> 
> Doesn't help:
> 
>     module a;
>     void bar(int x) {
>         assert(x > 0);
>         writeln("x = ", x);
>     }
>     // --------
>     module b;
>     import a;
>     void foo(int x) {
>         enforce(x > 0);
>         bar(x);
>     }
> 
> If `assert` is treated like `assume` (under Ola's definitions), then
> `enforce` can be optimized away.

Wait, what? I thought the whole point of enforce is that it will *not*
be removed by the compiler, no matter what?


T

-- 
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it. -- Brian W. Kernighan


More information about the Digitalmars-d mailing list