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

Uoti Urpala uoti.urpala
Mon Apr 7 21:49:23 CEST 2008


On Mon, 2008-04-07 at 21:31 +0200, Michael Niedermayer wrote:
> On Mon, Apr 07, 2008 at 04:17:55PM +0300, Uoti Urpala wrote:
> > 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
> > behavior.
> 
> It seems the comittee does not agree with your interpretation
> see Defect Report #081:
> http://www.open-std.org/JTC1/SC22/WG14/www/docs/dr_081.html
> It is implementation defined not undefined.

"Submission Date: 03 Dec 93". That can't be for the current version of
the C standard. The answer there seems to be that left shifting signed
values as a whole is implementation-defined.

The current standard says: (E1 << E2) If E1 has a signed type and
nonnegative value, and E1 * 2^{E2} is representable in the result type,
then that is the resulting value; otherwise, the behavior is undefined.

So the current standard never leaves it implementation-defined. The
result is specified when there is no "overflow" and otherwise the
behavior is undefined.





More information about the ffmpeg-devel mailing list