And thus spake James Kanze <
[email protected]>
Sat, 13 Mar 2010 15:23:19 -0800 (PST):
Well, you do live in a very interestingly limited world it
seems.
Very limited, yes. Limited to five or six different compilers,
on as many different systems.
And labeling more or less everyone who does not agree with you
as unprofessional is quite an interesting statement as well.
There's such a thing as professional ontology.
At my company, we _do_ have two different builds, one for
debugging and one for release. The application is very
performance-sensitive. In the debugging version, all sorts of
sanity checks and asserts are active, which slow the code down
by an additional factor of 5-10 (apart from the lack of
optimisation), but which help to make sure that the geometry
core is in fact doing something mathematically sane.
There are certainly cases where it's justified. Just as there
are cases where three or more modes are justified: if some
checks mean that it takes two hours, instead of ten minutes, to
get the the error location, then you have a build which turns
those checks off, and only those checks.
Apart from that, asserts do not always make sense in non-debug
code anyway. For example, I currently also develop a graphics
transformation library. If I build it with fully optimisation,
it becomes faster by a factor of 10-20 (among other things due
to massive inlining). However, it is more or less _impossible_
to debug when built fully optimised, so active asserts would
not do much good anyway.
By the way, the standard 'assert' macro defined in the
standard IIRC is explicitely disabled if 'NDEBUG' is defined,
and setting this preprocessor symbol also disables all sorts
of range checks etc.
It shouldn't. Typically, in the compilers I've used (including
VC++), there have been any number of different options
controlling different aspects of checking.
in STL containers at least in VC++, if I am not mistaken.
Debugging in STL containers in VC++ is definitely separate from
NDEBUG, since in most of our build configurations, we have
asserts turned on, but most of the checks in the STL turned off.
So in my opinion it could in fact be quite common that asserts
are inactive in production code, at least if it is
performance-critical code built with full optimisation.
That's a big if. Even today, most (not all) programs are IO
bound, and are delivered without optimization, because compiler
optimizations don't speed up disk.