iris.c
iris.c copied to clipboard
-Wshift-negative-value warning in jpeg.h
When compiling jpeg.h with gcc, the compiler emits a -Wshift-negative-value warning in jpeg_extend
jpeg.h: In function 'jpeg_extend':
jpeg.h:377:21: warning: left shift of negative value [-Wshift-negative-value]
377 | v = v + (-1 << bits) + 1;
| ^~
The expression -1 << bits left-shifts a negative signed integer, which is undefined behavior in C.
The proposed fix:
/* before */
v = v + (-1 << bits) + 1;
/* after */
v = v - (1 << bits) + 1;
Want me to send a one-line pull request for this?