On Apr 7, 5:04 pm, Ron Natalie <r...@spamcop.net> wrote:
> James Kanze wrote:
> > Using the [] operator with an out of bounds value is undefined
> > behavior. In any modern implementation, I would expect an
> > assertion failure, or something similar. (It's the case with
> > g++ and VC++, at least.)
> Provided you are in a mode with such assertions turned on.
> VC++ won't do it in release mode.
Now Ron, you know better

. The compiler does what you tell it to
do. And VC++ (like every other compiler) offers tons of
options, not just one or two modes. The code I deliver has the
assertions turned on unless there is a real performance
problems.
It is true that typically, code compiled with them on and code
compiled with them off cannot be linked together. (Worse: at
least with g++, it can be linked without problems; it just core
dumps when you run it.) Which means that one tight loop, and
you have to recompile the entire application and all libraries
with it turned off everywhere.
This also means that if I'm delivering a library, I have to
deliver it in two versions, since I can't know in advance
whether the client code will have a performance problem
elsewhere which will require turning the assertions off.
--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34