Assert question

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 26 05:24:59 PDT 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


More information about the Digitalmars-d-learn mailing list