Could the values of an undefined behaviour be predicted somehow?
Could the values of an undefined behaviour be predicted somehow?
No, but in practice, it depends, since a particular compiler may be known to do something for certain cases that result in undefined behaviour.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Plus the little problem that if something is undefined, it may work perfectly on one compiler but fall flat on it's face on another...
A better name might be "unpredictable behaviour"...
> Could the values of an undefined behaviour be predicted somehow?
What did you have in mind - tea leaves, crystal ball, tarot cards, chicken entrails....
It's a pointless excercise; whatever it is you think you "know" about the undefined behavior is immediately invalidated with the next edit or the next compile.
Just look at how much "fun" there is to be had, even with simple programs. Using visual studio would really keep you on your toes!
Here's another term for it.
Cargo cult programming - Wikipedia, the free encyclopedia
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.