Ralf Wildenhues wrote:
* Paul Eggert wrote on Wed, Dec 20, 2006 at 08:38:56AM CET:
Here's a patch that would allow programs to avoid running afoul of
unexpected gotchas with signed integer overflow when being compiled by
GCC using the default compilation flags. It also attempts to document
the issue. Comments?
Thank you for writing the patch, a couple of nits inline.
I absolutely oppose this patch. I have never, ever found a problem with
the optimizations that GCC currently implements when -fwrapv is given;
while -fwrapv severely pessimizes performance on several programs of
mine. The common idioms are actually not optimized by GCC, and some
uncommon idioms have been optimized between 1992 and 2003 without any
option to disable these optimization (and without anybody noticing?).
C is not anymore a high-level assembly language, and the compiler has
every right to optimize, e.g., a*2/2 to a, or to assume that (signed)
induction variables don't overflow. Move on, and read the language
standard.
Paolo