3 ms·
http://www.emulators.com/docs/LazyOverflowDetect_Final.pdf http://www.emulators.com/docs/LazyOverflowDetect_Final.pdf This paper seems to imply that that high l
by throwawayaway 12y ago
http://www.emulators.com/docs/LazyOverflowDetect_Final.pdf http://www.emulators.com/docs/LazyOverflowDetect_Final.pdf
This paper seems to imply that that high level languages can't access the carry bit, yet C#'s checked mechanism uses it.
I've been using -ftrapv with gcc for a long time, from here:
https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.
From the code you posted, and the assembly[1] emitted in the pdf above I can't see the optimiser taking advantage of the carry bit. No mention of CF, OF:
[1]
lea ebx, DWORD PTR [edi+eax]
cmp ebx, edi
jae SHORT $LN4@unsigned_c
cmp ebx, eax
jae SHORT $LN4@unsigned_c
mov ecx, 1
jmp SHORT $LN5@unsigned_c
xor ecx, ecx
The gcc flag ftapv only works for signed integers, not clear what the carry bit behaviour is for unsigned integers.