[FFmpeg-devel] [PATCH] Cast AV_NOPTS_VALUE to int64_t implicitly

Nicolas George nicolas.george at normalesup.org
Wed Sep 19 19:58:55 CEST 2012


Le jour de la Raison, an CCXX, Reimar Döffinger a écrit :
> > -#define AV_NOPTS_VALUE          INT64_C(0x8000000000000000)
> > +#define AV_NOPTS_VALUE          (int64_t)INT64_C(0x8000000000000000)
> Hm, I kind of wonder if that warning behaviour is actually matching
> the C standard, as hard to believe as that may be.

You might be right. If I read the standard correctly, an integer constant in
C does not include the sign: "-42" is not the integer constant -42 but the
unary minus operator applied to the integer constant 42.

The thing is, since 0x8000000000000000 does not fit in a signed long (or
long long, depending on arch), it is considered as an unsigned long,
according to the table in section 6.4.4.1. The INT64_C macro only adds the
"L" suffix, it does not change it. Therefore, the minus is considered
unsigned, resulting in 0x8000000000000000 itself. The cast is then an
integer overflow assuming 2's complement.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120919/1854961f/attachment.asc>


More information about the ffmpeg-devel mailing list