[Coin-lpsolver] Assert Problems

J P Fasano jpfasano at us.ibm.com
Tue Mar 1 11:14:59 EST 2005





> You raise an interesting issue on asserts and I would welcome
> discussion.  I can see three sorts of uses of assert -
> 1) Double checking on some logical error - in my case that might be
> an array that is marked as all zero when it is not.  This is
> sometimes but not always on a -Dxxx_DEBUG flag given to compiler.
> 2) Something that should not happen but the code will recover - it
> may have happened once and I want to track it down.
> 3) Something that should not happen but the code can't recover.
>
> At present with gcc and optimization -DNDEBUG is set and with some
> other compilers that is also true.  So in that case all asserts are
> null tests.  So it is perfectly possible that your error would go
> away if you used a greater optimization level.  However that is
> obviously not acceptable.
>
> As asserts slow down the code I could look into using CoinAssert
> which we could define.  This could print the same message but throw
> a clean exception.

I would call it CoinException, or better use and possibly enhance the
existing class CoinError.

> I would leave some type 1 asserts as they are
> but change others.  Comments?

I agree type 1 can be an assert.





More information about the Clp mailing list