iris.c icon indicating copy to clipboard operation
iris.c copied to clipboard

-Wshift-negative-value warning in jpeg.h

Open vincenzoaurelio opened this issue 2 weeks ago • 0 comments

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?

vincenzoaurelio avatar Nov 17 '26 20:11 vincenzoaurelio