assert(0) behavior

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 3 08:50:56 PDT 2015


On 8/3/15 11:18 AM, Dicebot wrote:
> On Monday, 3 August 2015 at 14:34:52 UTC, Steven Schveighoffer wrote:
>> Why do we do this?
>
> Because all asserts must be completely removed in -release

1. They aren't removed, they are replaced with a nearly useless segfault.
2. If we are going to put something in there instead of "assert", why 
not just throw an error?

Effectively:

assert(0, msg)

becomes a fancy way of writing (in any mode, release or otherwise):

throw new AssertError(msg);

This is actually the way I thought it was done.

-Steve


More information about the Digitalmars-d mailing list