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

Era Scarecrow rtcvb32 at yahoo.com
Sat Oct 27 12:03:05 PDT 2012


On Saturday, 27 October 2012 at 18:36:57 UTC, H. S. Teoh wrote:
> On Sat, Oct 27, 2012 at 08:26:21PM +0200, Andrej Mitrovic wrote:
>> Maybe related to -release?
>
> Haha, you're right, the assert is compiled out because of 
> -release.

  Then it is a bug; Unless perhaps it is inside a contract 
(in/out) or debug statement.

  TDPL pg 326:
[quote]
  An assertion against a constant that is known to be zero during 
compilation, such as assert(false), assert(0), or assert(null), 
behaves a tad differently from a regular assert.

  In non-release mode, assert(false) does not do anything special: 
It just throws an AssertError exception.

  In release mode, however, assert(false) is NOT compiled out of 
existence; it will always cause a program to stop. This time, 
however, there would be no exception and no chance of continuing 
to run after an assert(false) was hit. The program will CRASH.
[/quote]



More information about the Digitalmars-d mailing list