Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-10-10 13:38:47

From: Jason Hise <chaos_at_[hidden]>
> Dave Harris wrote:
> >In-Reply-To: <4343103A.6010007_at_[hidden]>
> >darren_at_[hidden] (Darren Cook) wrote (abridged):
> >
> >>I think it is fair to assume people don't have assert(false) in code
> >>that is ready for release - it is just used temporarily during
> >>debugging.
> >
> >No, it isn't fair to assume that. I have:
> >
> > if (e) {
> > assert(false);
> > throw "can't happen";
> > }
> >
> >or similar in release code.
> >
> Isn't that an abuse of assert? IOW, shouldn't you either make it

Not at all.

> exclusively a debug mode check, or make it a check in both modes? It
> seems that that should either become:
> assert ( !e );
> or:
> if ( e ) throw "can't happen";
> Why do you need both types of checks in the same place?

That way a debug build asserts, which likely gets a core dump,
and a release build throws an exception. If the exception is a
type that is never caught in the code except in main(), then
main() can report the problem and exit. That gives a clean exit
with a diagnostic in release builds, while giving the opportunity
for post mortem debugging in debug builds.

Rob Stewart                           stewart_at_[hidden]
Software Engineer           
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at, gregod at, cpdaniel at, john at