Thread overview
Assert question
Jul 26, 2016
DLearner
Jul 26, 2016
Adam D. Ruppe
July 26, 2016
Suppose a program contains several points that control should not get to.
So each such point is blocked by assert(0).
What is the recommended way of identifying which assert has been triggered?

Is one allowed anything like 'assert(0,"Crashed at point A");', where the message goes to stderr?
July 26, 2016
On 7/26/16 8:13 AM, DLearner wrote:
> Suppose a program contains several points that control should not get to.
> So each such point is blocked by assert(0).
> What is the recommended way of identifying which assert has been triggered?
>
> Is one allowed anything like 'assert(0,"Crashed at point A");', where
> the message goes to stderr?

In non-release mode, assert(0, msg) prints the message (an error is thrown). In release mode, the assert(0) halts the program immediately and does not print any message.

So yes and no :)

-Steve
July 26, 2016
On Tuesday, 26 July 2016 at 12:13:02 UTC, DLearner wrote:
> What is the recommended way of identifying which assert has been triggered?

If you compile with -g, run the program in a debugger. It will tell you.

If you compile and do NOT use -release, the error message automatically printed by the assert will tell you the line number on the first line of output.