Adventures in undefined behavior: The premature downcast
A customer encountered the following problem: The function converts the cookie back to a object, and then checks if the object is a object by calling . If so, then it does some more stuff to figure out what type of paint to buy. (Note to nitpickers: The actual scenario was not like this, but I presented it this way to illustrate the point....