How to make invariant switchable

Max Samukha outer at space.com
Thu Jun 18 10:13:19 PDT 2009


On Thu, 18 Jun 2009 19:28:41 +0400, "Denis Koroskin"
<2korden at gmail.com> wrote:

>On Thu, 18 Jun 2009 17:46:37 +0400, Max Samukha <outer at space.com> wrote:
>
>> On Thu, 18 Jun 2009 17:12:25 +0400, "Denis Koroskin"
>> <2korden at gmail.com> wrote:
>>
>>> On Thu, 18 Jun 2009 17:09:12 +0400, Qian Xu  
>>> <quian.xu at stud.tu-ilmenau.de>
>>> wrote:
>>>
>>>> Denis Koroskin wrote:
>>>>>
>>>>> No, they wont.
>>>>
>>>> Is there any reason for that?
>>>
>>> I dont know. I'd prefer to write
>>>
>>>> debug assert(foo == bar, "foo must be equal to bar");
>>>
>>> if I'd like to turn them off in release mode.
>>
>> 'debug' is not necessary in most cases because asserts are removed
>> from release builds unless the assert condition is known to be false
>> at compile time, in which case a hlt instruction is generated for the
>> assert in release mode.
>
>You must have misunderstood my post.

Sorry, I understand now.

>
>I know that asserts are removed in release mode. Why question was, why  
>they are removed?
>I responded that I personally see no reason in removing them in release  
>mode.
>I wrote that if I were to remove my asserts in release, I would prepend  
>them with "debug":
>
>debug assert(condition, errorMessage);

Why would you want to leave asserts in a release build while they are
supposed to be used for debugging?



More information about the Digitalmars-d mailing list