"puzzlecracker" <ir*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com
the behavior is undefined - but why does it work on all compilers?????
I doubt that you have tested all compilers.
You really need to get over this nonsense. Undefined means that anything can
happen. Included in the "anything" is that it might work as you expect.
There is no explanation in standard C++ as to why something with undefined
behaviour might "work". That all depends on the details of compiler
implementations etc. If you want to know, then go ask the authors of the
compiler.
If you write correct code, you are entitled to expect it to work. If you
write code that invokes undefined behaviour, you have no right to expect
anything. The fact that code with undefined behaviour sometimes works in the
way expected by the programmers who write it is neither new nor interesting
information. Programmers who rely on such "good fortune" are fools.
--
John Carson