Re: We do not use C++ exceptions
On Jan 28, 1:19 am, Bernhard Jungk <bernh...@projectstarfire.de>
wrote:
If you don't catch all invalid values, what's the point of checking at all?
That's like saying "if your tests do not prove with certainty that
your program is correct, what's the point of testing at all?"
The point is to have less bugs.
E.g. if you do allocate memory based on some value you read in from some
network? There may still be some security vulnerabilty! Catching some
errors is not much better than catching less errors.
Yes it is. In the "allocate memory" case, the assert firing would
indicate that the programmer who parsed the network packet had a bug
in his validation code, a bug which his unit test (coupled with an
absence of asserts) did not catch. This does happen.
Therefore in your
example the programmer has to check a, b, c and d, and therefore making
the "<0" assertion redundant.
Sure. If everyone writes perfect code, all memory bits are completely
stable, there are no calling convention mismatches, and there are no
dangling pointers (which is, on second thought, implied by the perfect
code), assertions are redundant. I myself prefer the redundancy.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]