All you say is so true it is actually a truism. It is clear to all but the greenest neophytes and is actually the basis for this assignment. Additionally, while the standard which describes all implementations cannot make predictions about UB, in most given real systems (architecture, compiler, options) you do get reproducible results, and people do use that, usually for illicit purposes. This was a homework specifically asking to exploit the specific behavior of a specific system. Saying that the standard does not define the behavior utterly misses the point.
↧