checkedint call removal

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 12:40:15 PDT 2014


On 07/30/2014 09:16 PM, H. S. Teoh via Digitalmars-d wrote:
> 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
>

That's approximately the crux of the matter, yes. :-)


More information about the Digitalmars-d mailing list