Slamming the Door

        Submitter: Omer Mussaev

        Language: C, C++

        Date:         2004/02/07

How do you tell your program to exit? 

There are many polite ways. However, there are rude and impolite ways as well. One of them is assert(false).

The immediate effect of the above is crash, drawing a lot of attention from everybody who happens to be near. If the only people around are developers who implement the product then every bit of their attention will count. If however, some of those present happen to be customers, or worse, prospective customers during a sales presentation, than this exit strategy can be a show stopper. 

---------------------------------------------------

Oleg Goldshmidt:

The above is true, of course, only if you ship the product with debugging code still in. If you ship optimized code then assert() will do exactly nothing, with totally unpredictable consequences. This has been beaten over the head elsewhere in these pages.