assert, NDEBUG and you

Michael Stefaniuc mstefani at redhat.com
Mon Oct 26 17:31:33 CDT 2015


On 10/26/2015 09:51 PM, Chris Robinson wrote:
> On 10/26/2015 09:31 AM, Michael Stefaniuc wrote:
>> I guess you'll have to show that the assert() has a real impact in an
>> application. Else it doesn't matters.
> 
> I think the question should be the other way around, asking first "is
> this check/assert needed?" rather than later "should we get rid of this
> check/assert?". If a check is only needed at certain times (i.e. when
> developing around the code), then you can get rid of it when it's not
> those times. One assert() may be imperceptible, but hundreds or
> thousands sprinkled around the code base can cause execution to be slow
> in general with no specific choke point.
You've removed the context but I was strictly referring to the case that
he mentioned that the assert() is useful to have but it would be too
expensive to use just a plain assert().

I'm too the opinion that code with too many assert()s sprinkled in is
unfinished code and shouldn't go in as is. Of course it can go into
Staging that way. But even in that case you want a plain  assert() and
not a wrapper that is disabled for users., User feedback is an important
part of the development process.

And last but not least, IMHO, crashing is the far better response than
silently corrupting user data. So yes, using -NDEBUG is misguided.

bye
	michael



More information about the wine-devel mailing list