[FFmpeg-devel] [PATCH] all: silence clang -Wabsolute-value for unsigned subtractions
michael at niedermayer.cc
Mon Aug 24 00:58:20 CEST 2015
On Sat, Aug 22, 2015 at 04:26:53PM +0200, Nicolas George wrote:
> Le quintidi 5 fructidor, an CCXXIII, Ganesh Ajjanagadde a écrit :
> > + /* cast for -Wabsolute-value in clang 3.5+ */
> > + return abs((int) (t1 - t2)) + abs((int) ((c1 & 0x000000ff) - (c2 & 0x000000ff))) +
> > + abs((int) (((c1 & 0x0000ff00) >> 8) - ((c2 & 0x0000ff00) >> 8))) +
> > + abs((int) (((c1 & 0x00ff0000) >> 16) - ((c2 & 0x00ff0000) >> 16)));
> I believe this is not correct, with or without the cast (the cast is
> implicit due to the prototype of abs(), of course): if the result is morally
> negative, converting the morally-negative unsigned to signed is an undefined
i dont know what "morally negative" means exactly but convertion
of out of range values to signed integers is not undefined behavior
in C. It is implementation defined or raises a implementation defined
Please see 188.8.131.52 Signed and unsigned integers in ISO/IEC 9899:TC3
I doubt that FFmpeg will work on platforms that
define this significantly differently than how it is defined for the
currently supported platforms,
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 181 bytes
Desc: Digital signature
More information about the ffmpeg-devel