When I answered this question, I wrote:
First, it is important to note that it is not only the behaviour of the user program that is undefined, it is
is it only the behaviour of the translated machine code that is undefined, or is the behaviour of the compiler undefined, too?
The ISO C and C++ describe what a C and C++ program look like. They do not describe the environment they run in. We generally use the term compiler to refer to the tool that translates C and C++ into machine code; formally, however, the term used is implementation which is definitely wider.
Therefore, the only behavior which is undefined is the one of the program. This is also given by the definition of UB:
undefined behavior
behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements