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
If a code has undefined behaviour it means that the standards does not know how to handle such thing. Thus it can give any output. I think it doesn't have to do with compiler as it doesn't make sense. It makes sense that it has to be the implementation that works according to standards.
So, if standards don't know how to handle such code, then how can compilers give a defined output?