[FFmpeg-devel] [RFC] Sechole in gcc 3.3+ and 4.*

Uoti Urpala uoti.urpala
Mon Apr 7 15:17:55 CEST 2008

On Mon, 2008-04-07 at 15:02 +0200, Michael Niedermayer wrote:
> On Mon, Apr 07, 2008 at 03:38:31PM +0300, Uoti Urpala wrote:
> [...]
> > ---
> > Part 6.5 Expressions:
> > If an exceptional condition occurs during the evaluation of an
> > expression (that is, if the result is not mathematically defined or not
> > in the range of representable values for its type), the behavior is
> > undefined.
> > ---
> > 
> > If the sum of signed variables overflows the above applies. The unsigned
> > behavior of always reducing mod size (which means the result is always
> > representable) is described elsewhere.
> Twos complement addition, subtraction and multiplication are identical to
> their unsigned counterparts. That is they form in isomorphism relative to
> them.

C does not require that to be true. It does not require signed numbers
to be two's complement either.

> They are mathematically well defined as +,* in Z/nZ with n=2^bits. And their
> values are representable, after all the identical opertation called unsigend
> has them representable.
> If C meant this to be undefined they could have said so explicitly like they
> do for >> and signed numbers.

The shift operators mention that separately because they're defined as
"bit shift" rather than a mathematical operation defined on all
integers. Note that here too the case that is "not representable" with
signed numbers ("overflowing" <<) is consistently specified as undefined
>> with negative numbers is implementation-defined, not undefined.

More information about the ffmpeg-devel mailing list