3 ms·
But that code code is wrong in the first place with defined overflow. If x == 0x804021 then x * 0x1FF yields 0x1DF, and then proceeed to access tab[0]. This is
by p0nce 4y ago
But that code code is wrong in the first place with defined overflow.
If x == 0x804021
then x * 0x1FF yields 0x1DF, and then proceeed to access tab[0]. This is very probably NOT what the author wanted.
- Defined overflow doesn't help at all, in fact the compiler would preserve what is wrong in the first place
- overflow trap is a little bit better, at least you would get the occasion to think about it
Even if the compiler doesn't act on the UB the code is still wrong.