[FFmpeg-devel] [RFC] Sechole in gcc 3.3+ and 4.*
Michael Niedermayer
michaelni
Mon Apr 7 15:42:10 CEST 2008
On Mon, Apr 07, 2008 at 03:25:41PM +0200, Michael Niedermayer wrote:
> On Mon, Apr 07, 2008 at 04:17:55PM +0300, Uoti Urpala wrote:
> > 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.
>
> It does require the implemention to specifiy it:
> ------
> J.3 Implementation-defined behavior
> 1 A conforming implementation is required to document its choice of behavior in each of
> the areas listed in this subclause. The following are implementation-defined:
> ...
> -- Whether signed integer types are represented using sign and magnitude, two's
> complement, or ones' complement, and whether the extraordinary value is a trap
> representation or an ordinary value (6.2.6.2).
> ------
Also:
2 For signed integer types, the bits of the object representation shall be divided into three
groups: value bits, padding bits, and the sign bit. There need not be any padding bits;
there shall be exactly one sign bit. Each bit that is a value bit shall have the same value as
the same bit in the object representation of the corresponding unsigned type (if there are
M value bits in the signed type and N in the unsigned type, then M <= N ). If the sign bit
is zero, it shall not affect the resulting value. If the sign bit is one, the value shall be
modified in one of the following ways:
-- the corresponding value with sign bit 0 is negated (sign and magnitude);
-- the sign bit has the value -(2^N ) (two's complement);
-- the sign bit has the value -(2^N - 1) (ones' complement).
Which of these applies is implementation-defined, as is whether the value with sign bit 1
and all value bits zero (for the first two), or with sign bit and all value bits 1 (for ones'
complement), is a trap representation or a normal value. In the case of sign and
magnitude and ones' complement, if this representation is a normal value it is called a
negative zero.
-------------
Above defines strictly how signed integers are represented on twos complement
systems. As a side effect this requires the +-* operations to be identical to
unsigned integers.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080407/60831ab4/attachment.pgp>
More information about the ffmpeg-devel
mailing list