[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: abort or verify?

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2004-11-11 03:38:08 CET

Branko Čibej <brane@xbc.nu> writes:

> Justin Erenkrantz wrote:
>
> >> Let me propose to use "verify" instead of "assert", where "verify" is
> >> defined to be the same as "assert" except that it is always enabled
> >> (i.e.
> >> even when NDEBUG is defined). This will achieve points (1), (2)
> >> and (3),
> >> and will leave the checks active all the time.
> >>
> >> Would this be acceptable to everyone?
> >
> >
> > I'm not sure how you'd have it defined to be the same. The
> > expansion of assert() is different on each platform, IIRC.
>
> Yes, but the following would almost do the trick:
>
> #define verify(x) do { assert(x); if (!(x)) abort(); } while(1)

Ha! I started to suggest the same thing earlier today before scolding
myself about adding more noise to this topic. But seeing the idea pop
up again, I'd like to add my +1 on this mechanism (though I have a
mild preference that "verify" be in all caps so it stands out as the
macro it is).

Rationale: I absolutely believe that all mis-uses of the API should
cause hard SEGFAULTs. But I do like the messaging you get from
assertion failures. I think the above perfectly maps to what I want
as the result of all this discussion.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Nov 11 03:41:10 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.