assert(0) behavior

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 3 20:04:10 PDT 2015


On Tuesday, 4 August 2015 at 02:37:00 UTC, Ola Fosheim Grøstad 
wrote:
> On Monday, 3 August 2015 at 15:18:12 UTC, 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
>>
>> Yet assert(0) effectively mean "unreachable code" (it is 
>> actually defined that way in spec) and thus it is possible to 
>> ensure extra "free" bit of safety by crashing the app.
>
> It isn't free. The point of having unreachable as primitive is 
> that you can remove all branching that leads to it.

"free compared to throwing exception" would be a better wording 
indeed. I remember Iain complaining about presence of HLT (and 
saying he won't do that for gdc) for exactly this reason.


More information about the Digitalmars-d mailing list