2 ms·
Even if the code would still be bad for 32-bit machines, I'm not sure they would suffer from the bug (if they had 32-bit signed int as well). 1. Your uint8_t w
by baby 9y ago
Even if the code would still be bad for 32-bit machines, I'm not sure they would suffer from the bug (if they had 32-bit signed int as well).
1. Your uint8_t would get promoted to a 32-bit int
2. Your int would get shifted, getting a 1 in the signing bit
3. The result would get stored in a uint32_t when being casted
Now I don't know how uint64_t works on a 32-bit machine, I'd have to compile the C code with -m32 to see.
EDIT: just tested and you're right, it's still a problem on 32-bit machines.