This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
- From: Roger Sayle <roger at www dot eyesopen dot com>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, <gcc at gcc dot gnu dot org>
- Date: Thu, 13 Feb 2003 08:15:25 -0700 (MST)
- Subject: Re: [PATCH] Document arithmetic overflow semantics
> We've said many times that a program that contains an expression of
> the form
> i = i++;
> need not produce the same results in different optimization levels.
> You seem to be trying to divide the set of things that make a program
> undefined into two sets: those that we must preserve over optimization
> and those that we need not. What criteria do you propose to use to choose,
> for each example of undefined behavior, which of those cases we apply?
What makes a program undefined is specified by the front-end's language
specification. This I have absolutely no comment on. In some languages
"i = i++" has precisely defined behaviour, in others it does not.
The issue is GCC's internal representations, which shouldn't suffer
from the same issue of poorly defined languages. Hence, if CSE sees
"x = i++; i = x" it had better understand exactly what "i = i++" means
at the RTL-level. One might hope that the interpretation of RTL and
TREEs are independent of the source language and target architecture.