This is the mail archive of the
mailing list for the GCC project.
Re: [bug-gnulib] GCC optimizes integer overflow: bug or feature?
- From: Bruno Haible <bruno at clisp dot org>
- To: gcc at gcc dot gnu dot org
- Cc: bug-gnulib at gnu dot org, Paul Eggert <eggert at cs dot ucla dot edu>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Tue, 19 Dec 2006 22:49:32 +0100
- Subject: Re: [bug-gnulib] GCC optimizes integer overflow: bug or feature?
- References: <20061218230847.GD3824@iam.uni-bonn.de> <Pine.LNX.firstname.lastname@example.org> <email@example.com>
Paul Eggert wrote:
> Compiling everything with -fwrapv is simple. It has
> optimization drawbacks, but if that's the best we can do
> now, then we'll probably do it. And once we do it, human
> nature suggests that we will generally not bother with the
> painstaking analysis needed to omit -fwrapv.
Certainly noone will try to analyze megabytes of source code in order to
someday be able to omit -fwrapv from the CFLAGS.
But if GCC would give a warning every time it does these optimizations which
are OK according to C99 but break LIA-1 assumptions, it would be manageable.
This way, programmers would have a chance to use 'unsigned int' instead of
'int' in those few places where it matters.
Such a warning should be simple to implement: Everywhere you use the value
of 'flag_wrapv' in a way that matters, give a warning. No?