Re: Assertion vs Exception Handling
On Mar 16, 9:55 am, ytrem...@nyx.nyx.net (Yannick Tremblay) wrote:
In article
<6d16782c-9284-46de-bbb9-67ff0b415...@x12g2000yqx.googlegroups.com>,
James Kanze <james.ka...@gmail.com> wrote:
[...]
I'd agree that it is worthwhile to ship code with asserts.
However, I'd disagree that you should not turn on optimisation
shipping code. Compiler optimisation can make a huge
difference and very importantly, it allow the developers to
write clear, safe and maintainable code and let the compiler
do it's job.
That's the theory. In practice, the risk of hitting a compiler
bug is significantly greater when optimization is turned on. In
theory, the semantics of optimized code are identical to those
of non-optimized code, and compiler optimization should be
nothing but a win. In practice... I recently lost three weeks
tracking down a bug due to the fact that VC++ doesn't always
call destructors in optimized mode.
Turning off compiler optimisation incur the very big risk of
programmers trying to do the copmpiler job and start writing
obfuscated code because they think it will be more efficient.
If the code is insufficiently fast without optimization, then
turning on optimization is generally the first thing you should
do; it's by far cheaper than having programmers spend time
optimizing manually. But until it's proven that the code is
insufficiently fast without optimization, you're better off
avoiding it.
--
James Kanze