[FFmpeg-devel] [PATCH] Cast AV_NOPTS_VALUE to int64_t implicitly
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 184.108.40.206. 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the ffmpeg-devel