Confusion over enforce and assert - both are compiled out in release mode

Andrew Chapman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 27 03:17:47 PDT 2017


On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote:
> On 08/27/2017 12:02 PM, Andrew Chapman wrote:
>> However, I am finding that BOTH enforce and assert are 
>> compiled out by dmd and ldc in release mode.  Is there a 
>> standard way of doing what enforce does inside an "in" 
>> contract block that will work in release mode?
>> 
>> I'm guessing I should write my own function for now.
> The whole `in` block is ignored in release mode. Doesn't matter 
> what you put in there. Nothing of it will be compiled.

Thanks, that explains it.  I think it's a bit of a shame that the 
"in" blocks can't be used in release mode as the clarity they 
provide for precondition logic is wonderful.


More information about the Digitalmars-d-learn mailing list