Peter N Lewis wrote:
At 20:18 +0200 2/8/06, Frank Heckenbach wrote:
Peter N Lewis wrote:
I have a lot of assertions. If one of them fails, GPC only reports something like "assertion failed (error #306 at 40dd45)". How can I find out the exact assertion that failed?
Rather than use the built in assertions, we use our own assertions, that way it allows us to compile them out of the later beta/final builds (a requirement for over-asserting as recommended by Writing Solid Code which should be essential reading for any programmer).
BTW, you can also do this with GPC's built-in assertions, using the option "--no-assertions".
Has this changed then? The docs I have say:
However, if the switch '--no-assertions' is given (see Section 5.1 [GPC Command Line Options], page 33), 'Assert' is deactivated. It still evaluates the condition if it has side effects, but never raises a runtime error.
In which case the evaluation would still be called, which means expensive evaluations cannot be left in...
No, it hasn't changed. (I said the assertions can be turned off, nothing about side-effects.)
To avoid expensive computations (when the compiler can't tell they have no side-effects), you can put them in "{$ifopt assertions}" -- either the code that calls Assert, or functions that perform them and become side-effect free nops otherwise.
Frank