assert(false, "...") doesn't terminate program?!
Walter Bright
newshound2 at digitalmars.com
Tue Oct 30 14:52:40 PDT 2012
On 10/30/2012 5:53 AM, Don Clugston wrote:
> > I think the code would be
>> better written as:
>>
>> if (toInt() == 0) throw new Error();
>>
>> If you really must have a divide by zero fault,
>>
>> if (toInt() == 0) divideByZero();
>>
>> where:
>>
>> void divideByZero()
>> {
>> static int x;
>> *cast(int*)0 = x / 0;
>> }
>
> And that works because writes to 0 _are_ considered a side-effect?
> Is that guaranteed to work?
Writing through a pointer is considered a side effect.
More information about the Digitalmars-d
mailing list