|
|
|
|
|
by rseacord
2251 days ago
|
|
Some example of hardware variation (since you mentioned shifting and overflow): - signed integer overflow or division by zero occurs, a division instruction traps on x86, while it silently produces an undefined result on PowerPC
- left-shifting a 32-bit one by 32 bits yields 0 on ARM and PowerPC, but 1 on x86;
- left-shifting a 32-bit one by 64 bits yields 0 on ARM, but 1 on x86 and PowerPC |
|
So x86 actually has both behaviors in one box (three behaviors if you could the 32-bit and 64-bit scalar things you mentioned separately).
This is an example of where UB for simple operations actually helps even on a single hardware platform: it allows efficient vectorization.