The effect of UB is arbitrary and can change between compilers, between versions of the same compiler, between optimization levels of the same compiler version, between different platforms targeted by the same compiler, etc. It also can change depending on what other code is in the same compilation unit (which, with LTO, means any other code anywhere in the program can affect the behavior)
When you say "this UB does ... (like generates a trap instruction)" you are being hyper specific for a given compiler version and platform and optimization level and any other knob. It may not stay the same after you update the compiler. And what happens a lot is that newer, better optimizations (such as more opportunity to autovectorization), which attract people to newer compiler versions, may exploit UB in more creative ways.
For example, to exploit autovectorization, compilers may want to push some test out of a loop. If this test contains UB, this optimization will change where the UB is triggered. So that trap instruction may happen at a different place in the code, depending on optimizations.