* Andrew Haley: >> I wouldn't rule it out. Just use -fwrapv (perhaps after benchmarking >> to make sure that it doesn't make a difference). Other compilers will >> have similar switches. > > This is bad advice. -fwrapv suppresses loop optimizations. Some loop optimizations perhaps, which are likely not to be relevant for the code base in the question. > Given that it's not difficult to detect overflow with perfectly > compliant code, there's no point. The fully compliant solution has an additional performance overhead compared to the one that assumes -fwrapv. Instead of -fwrapv, you can rely on additional guarantees from the documentation, but for someone that ships code to be compiled with unknown GCC versions, this might not be the best solution.