2011/6/18 Måns Rullgård <[email protected]>:
> Yusuke Nakamura <[email protected]> writes:
>
>> 2011/6/18 Måns Rullgård <[email protected]>
>>
>>> Yusuke Nakamura <[email protected]> writes:
>>>
>>> > This patch fixes my 10L of following.
>>> >
>>> http://git.libav.org/?p=libav.git;a=commitdiff;h=5f0bb0baefd506d684adfa1ad4259c65973b455e
>>> >
>>> > From f3c030ebedabc9a17e377c6f91dc417e6578712b Mon Sep 17 00:00:00 2001
>>> > From: Yusuke Nakamura <[email protected]>
>>> > Date: Sun, 5 Jun 2011 01:28:43 +0900
>>> > Subject: [PATCH] mov: Fix empty edit detection.
>>> >
>>> > ---
>>> >  libavformat/mov.c |    2 +-
>>> >  1 files changed, 1 insertions(+), 1 deletions(-)
>>> >
>>> > diff --git a/libavformat/mov.c b/libavformat/mov.c
>>> > index e6ada4e..2d1d726 100644
>>> > --- a/libavformat/mov.c
>>> > +++ b/libavformat/mov.c
>>> > @@ -2230,7 +2230,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext
>>> *pb, MOVAtom atom)
>>> >              time     = avio_rb64(pb);
>>> >          } else {
>>> >              duration = avio_rb32(pb); /* segment duration */
>>> > -            time     = avio_rb32(pb); /* media time */
>>> > +            time     = (int32_t)avio_rb32(pb); /* media time */
>>>
>>> This cast is invalid if the value is >INT_MAX.
>>
>> What's wrong? If I get 0x80000000 from avio_rb32(pb), then I want to set
>> 0xffffffff80000000 to int64_t time.
>
> The cast is not guaranteed to do that.
>

On GCC it is...

C99 6.3.1.3 Signed and unsigned integers
>1 When a value with integer type is converted to another integer type other 
>than _Bool, if
>  the value can be represented by the new type, it is unchanged.
>2 Otherwise, if the new type is unsigned, the value is converted by repeatedly 
>adding or
>  subtracting one more than the maximum value that can be represented in the 
> new type
>  until the value is in the range of the new type.49)
>3 Otherwise, the new type is signed and the value cannot be represented in it; 
>either the
>  result is implementation-defined or an implementation-defined signal is 
> raised.

http://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html#Integers-implementation

> The result of, or the signal raised by, converting an integer to a signed 
> integer type when the value cannot be represented in an object of that type 
> (C90 6.2.1.2, C99 6.3.1.3).
>
> For conversion to a type of width N, the value is reduced modulo 2^N to be 
> within range of the type; no signal is raised

Do you know a compiler we support where it isn't? We do this all over
the code base.

--Alex
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to