This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
On Thu, Feb 13, 2003 at 07:22:42AM -0700, Roger Sayle wrote:
> Hi Richard,
> > I think that's backwards. If program in C, C++, or Ada generates an
> > overflow, that program is undefined. That means the optimizer can do
> > anything it wants to the program, which, in turn, means that the optimizer
> > can assume that overflow *does not* occur, and that allows a lot more
> > optimizations.
>
> I completely disagree, and so do GCC's patch reviewers.
Huh? I for one agree with Kenner. Using the undefinedness of
something to infer that it doesn't happen is well-established.
> The behaviour of a program with optimization should always be the
> same as its behaviour without optimization.
For conformant code, yes. For undefined code, no.
For a very popular example of this *not* happening for
non-conformant code is type-based aliasing. This regularly
catches folks by "mis-scheduling" their code.
r~