This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Joe Buck <jbuck at synopsys dot com>
- Cc: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>, roger at www dot eyesopen dot com, gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org, Richard dot Earnshaw at arm dot com
- Date: Thu, 13 Feb 2003 16:13:30 +0000
- Subject: Re: [PATCH] Document arithmetic overflow semantics
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> In C, it is frequently the case that defining the overflow behavior of
> signed integer in this way makes more optimizations possible. For one
> thing, it makes addition and multiplication associative. Without such
> an assumption, you can't turn (a+b)+c into a+(b+c), because the overflows
> might be different.
The same is also true if the operation saturates. I don't recall anything
in the C89 standard that says that signed arithmetic can't be implemented
on a saturating arithmetic machine.