3 ms·
Friendly reminder to use clang's and gcc's intrinsics to check for integer overflow (signed or unsigned): https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-B
by Kristine1975 10y ago
Friendly reminder to use clang's and gcc's intrinsics to check for integer overflow (signed or unsigned):
https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins...
http://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins http://clang.llvm.org/docs/LanguageExtensions.html#checked-a...
- pascal_cuoq 10y agoOn the other hand, using nonstandard extensions makes it harder to move away from a compiler the direction of which you are not happy with, and can make your situation worse in the long term.
- Kristine1975 10y agoJust put the intrinsics into their own functions and re-implement those when switching compilers.
- taneq 10y agoWouldn't this be a classic case where you'd encyst the nonstandard code in a library, making it simple to swap out the implementation if required?