assert(false, "...") doesn't terminate program?!

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Oct 27 11:39:04 PDT 2012


On Sat, Oct 27, 2012 at 08:26:21PM +0200, Andrej Mitrovic wrote:
> On 10/27/12, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> >         writeln("how did the assert not trigger??!!");	// how did we get
> > here?!
> 
> Maybe related to -release?
[...]

Haha, you're right, the assert is compiled out because of -release.

But I disassembled the code, and didn't see the "auto x = 1/toInt()"
either. Is the compiler optimizing that away?

Also, is that even a good idea? Shouldn't we be throwing an exception
here instead of trying to trigger integer division by zero (which may
not even terminate the program, depending on the OS, etc.)? Not to
mention, the failure of this line to stop the program causes the code to
return to the division function, which never terminates because of the
zero divisor.


T

-- 
The volume of a pizza of thickness a and radius z can be described by the following formula: pi zz a. -- Wouter Verhelst


More information about the Digitalmars-d mailing list