Possible Duplicates:
What’s the worst example of undefined behaviour actually possible?
What are all the common undefined behaviour that c++ programmer should know about?
What are the common undefined behaviours that Java Programmers should know about
There are lots of parts of the C and C++ standards that are not completely specified, because to do so might exclude some oddball architecture. Relying on the behavior of your particular compiler and CPU is generally frowned upon, for good reason. On the other hand some behaviors are so universal that you could easily get away with relying on them, even if it is technically undefined.
For example, initializing a pointer to 0xDEADBEEF could lead to bad results on a processor that traps on invalid pointer addresses. But I've never used such a processor, and I'll bet that you haven't either. I'm sure plenty of people have caught a bug or two with this technique, without any winged monkeys taking flight from their nostrils.
On the other hand, if you had old Mac code that depended on the endianness of the processor, you probably lived to regret that decision.
I'd love to see some real world examples of both good and bad reliance on unspecified behavior. It will be interesting to see which type gets the most votes.
There was a similar question with an entirely different emphasis: What’s the worst example of undefined behaviour actually possible?. I'm asking for examples where you are relying on the undefined behavior.