[FFmpeg-devel] [PATCH] Fix MSVC warnings about possible value truncation.

wm4 nfxjfg at googlemail.com
Sat Aug 30 11:21:53 CEST 2014


On Fri, 29 Aug 2014 15:52:25 -0700
Peter Kasting <pkasting at google.com> wrote:

> On Fri, Aug 29, 2014 at 3:48 PM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> 
> > Peter Kasting <pkasting <at> google.com> writes:
> >
> > > The attached patch fixes instances of MSVC warning
> > > C4244 about possible value truncation (e.g. when
> > > assigning double to float or int64_t to int).
> > > This warning is currently disabled in Chromium's
> > > MSVC build and
> >
> > > I'm trying to enable it.
> >
> > Why?
> > Did you find an actual issue?
> 
> 
> Yes, this warning can catch (and has caught, in Chromium) real bugs, where
> the compiler automatically truncated a value where the developer did not
> intend to do so.  In general, places that trigger it are worth being
> concerned about.

Littering the code with casts doesn't seem like a very good idea. I'd
expect it rather to hide bugs than to expose them. For example, it
could make a static analyzer with value range analysis stop working,
because the casts will basically throw a wrench into its algorithm.

> A couple of the places in this patch marked with "!!!" looked like
> potential bugs to me.  I'm not familiar enough with FFMPEG code to be
> certain.  This is why I'm asking reviewers not to rubber-stamp the changes
> here; even changes that simply make explicit the casts the compiler was
> previously doing implicitly may actually be incorrect behavior that should
> be fixed.
> 
> PK
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



More information about the ffmpeg-devel mailing list