I know exactly how it will behave in most of those scenarios.
Right up until an optimizing compiler throws your assumptions under the bus.
Compilers are allowed to (and both GCC and Clang frequently do) assume that your program will never invoke undefined behavior, and optimize accordingly.