[FFmpeg-trac] #7997(avcodec:closed): undefined-behavior at libavcodec/proresenc_anatoliy.c
FFmpeg
trac at avcodec.org
Thu Jan 9 17:48:58 EET 2020
#7997: undefined-behavior at libavcodec/proresenc_anatoliy.c
------------------------------------+-----------------------------------
Reporter: Suhwan | Owner:
Type: defect | Status: closed
Priority: normal | Component: avcodec
Version: git-master | Resolution: fixed
Keywords: ubsan | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+-----------------------------------
Comment (by mkver):
FFmpeg can choose to support only systems that support certain
requirements; if your system doesn't fulfill them, it's your problem. Just
saying.
Furthermore, you probably don't understand the important difference
between undefined and implementation-defined. The former allows a compiler
to presume that situations that trigger undefined behaviour simply don't
exist and optimize accordingly. In the situation of this patch, this means
that the compiler is allowed to infer that val is >= 0, because it is
left-shifted; and then this means that (val) >> 31 is 0 (presuming the
typical 32bit ints), so that the second part of said macro can be
eliminated. (This requires that both (val) in the macro are the same, i.e.
that they are not the result of some function-call that would get
evaluated twice (with possible side-effects and possibly different
results); this requirement is fulfilled here.) Implementation-defined
behaviour on the other hand does not confer said right on the compiler.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7997#comment:6>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list