Quoting Nicolas George (2020-05-21 17:10:00)
> Anton Khirnov (12020-05-21):
> > This is wrong. We should not fix warnings, we should fix bugs. Warnings
> > suggest there may be a bug, but not all warnings are correct.
> > 
> > In this case, I believe the warnings is invalid and there is no problem
> > to fix. It's correct that the comparison is always false on some
> > platforms, but AFAIK no standard we adhere to guarantees that on all
> > platforms.
> 
> Yet, we should strive to silence this warning, because invalid warnings
> distract from valid ones.
> 
> It is tricky to do elegantly.
> 
> Maybe:
> 
> static inline int
> check_overflow(size_t n, size_t s, size_t c)
> {
>     return n <= SIZE_MAX / s && n * s < SIZE_MAX - c;
> }
> 
> It would avoid the warning because n is size_t instead of unsigned.

I would lean towards disabling the warning instead.

It's only really useful for checking whether an unsigned value is
negative. In pretty much all other cases the warning is spurious because
even if the comparison is tautological on that specific system, it might
not be tautological elsewhere.

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to