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

Michael Niedermayer michaelni at gmx.at
Sat Aug 30 04:25:18 CEST 2014


On Fri, Aug 29, 2014 at 04:38:28PM -0700, Peter Kasting wrote:
> On Fri, Aug 29, 2014 at 4:26 PM, Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> wrote:
> 
> > First, this needs very, very careful review. I am not at all convinced
> > that these will not change behaviour.
> >
> 
> I strongly agree that it needs careful review.
> 
> I think that reinforces why a change like this is important.  These sorts
> of value truncations shouldn't just be invisibly, implicitly happening,
> since in many cases they can have important consequences.  If your code
> stores a double in a float, you should be thinking about whether precision
> loss is important.  If it stores a floating-point value in an integral one,
> you should be wondering if you need to round rather than truncate.  If it
> stores a 64-bit int in a 32-bit one, you should be thinking about potential
> integer overflow and whether the storage type needs to be increased to e.g.
> handle large files or long data streams.  Etc.

but ...

a = (uint8_t)b
doesnt (just) mean "hey i know a is uint8 and b is not, dont warn me"
it means
"truncate b to 8bit"
now if someone changed a to be 16bit or it was that in the first place
you might have a bug with the cast but not without and finding that
one could be tough

if this instead was something like
a  = (attribute(i know this casts to 8bit))b
or
a = /* truncate to uint8_t */ b
that IMHO would make alot more sense

also this patch seems to break the code
make fate ends in

make: *** [tests/data/ffprobe-test.nut] Error 134
make: *** Waiting for unfinished jobs....


> 
> Second, I believe powf and sinf are less commonly available than pow and
> > sin, so I think this will break compilation on some platforms (but haven't
> > double-checked).
> >
> 
> These are part of C99, so if platforms are at least C99-compliant, they

> should work.  Does FFMPEG support pre-C99 targets?

some

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140830/9b05d1fb/attachment.asc>


More information about the ffmpeg-devel mailing list