5 ms·
It's very worth pointing out and in fact advocating for the compiler options -fwrapv and -ftrapv Which both make signed integers take the expected two's comple
by boxfire 4y ago
It's very worth pointing out and in fact advocating for the compiler options -fwrapv and -ftrapv
Which both make signed integers take the expected two's complement behavior, or traps signed integer overflow, respectively.
N.B. left shifting into the sign bit is still undefined behavior... On x86-64 gcc and clang seem to perform the shift as if the number is interpreted unsigned, then shifted, then interpreted signed.