On Fri, Feb 18, 2011 at 4:14 AM, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: > On 18 February 2011 04:25, Jeffrey Walton wrote: >> I could never understand >> why POSIX specified that a program should abort after an assert >> (http://pubs.opengroup.org/onlinepubs/009695399/functions/assert.html). > > POSIX probably says that because C says that, and every implementation > does that, and standardising anything different would have been > incompatible with actual implementations. > > That's what assert does, it aborts the program if the assertion fails. > > If you want a different behaviour, don't use assert. Negative. Asserts are programmer diagnostics. They are a tool to aide in debugging. When debugging a program, it is useless behavior since there are a number of ways to deal with the condition which caused the assert to fire (including terminating the program). Other ways to deal with a failed assert would include changing a value which was unexpected. When a release build is created for the distribution of a program, NDEBUG is defined asserts are removed from the program. Those who don't define DEBUG nor NDEBUG should probably learn the make system - and take control of their preprocessor macros - rather than depending on automake and friends. Consider: I'm a dumb Windows guy, and I know debug builds use '-g3 -ggdb -O0 -DDEBUG', and release builds use '-g -O{2|3} -DNDEBUG'. Jeff