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

Don Clugston dac at nospam.com
Mon Oct 29 07:51:28 PDT 2012


On 27/10/12 20:39, H. S. Teoh wrote:
> 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?

Yes, and I don't know on what basis it thinks it's legal to do that.

> 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.)?

The intention was that it should behave _exactly_ like an integer 
division by zero.

It's bug 8021, BTW.


More information about the Digitalmars-d mailing list