This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Do CO++ signed types have modulo semantics?
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: Mark Mitchell <mark at codesourcery dot com>,Michael Veksler <VEKSLER at il dot ibm dot com>,Paul Koning <pkoning at equallogic dot com>,GCC Development <gcc at gcc dot gnu dot org>, gdr at integrable-solutions dot net,nathan at codesourcery dot com
- Date: Wed, 29 Jun 2005 09:59:41 -0700
- Subject: Re: Do CO++ signed types have modulo semantics?
- References: <20050629041841.GA11965@synopsys.com> <BEE7C89B.AA59%schlie@comcast.net>
On Wed, Jun 29, 2005 at 03:40:11AM -0400, Paul Schlie wrote:
> > Since you made an incorrect analysis, you draw incorrect conclusions.
>
> - fair enough, however it seems to me that assuming overflow does not occur
> and assuming overflows are trapped are logically equivalent?
No. Assuming overflows are trapped puts an unnecessary constraint on the
compiler. It prevents treating integer arithmetic as associative, for
example (as that might introduce a new trap).
> Overall, I guess I still simply believe the the first rule of optimization
> is to preserve existing semantics unless explicitly authorized otherwise,
> and then only if accompanied with corresponding warnings for all potentially
> behavior altering assumptions applied.
But C does not define the semantics of integer overflow, so there are no
existing semantics to preserve.