pnggroup / libpng

LIBPNG: Portable Network Graphics support, official libpng repository
http://libpng.sf.net
Other
1.25k stars 612 forks source link

pngfix: del workround for GCC7.1 -Wstrict-overflow #519

Closed jbowler closed 8 months ago

jbowler commented 8 months ago

Previously pngfix had been made warning-free in GCC7.1 by marking auto variables (volatile). This prevented the arithmetic optimizations which caused warnings from GCC7.1 with higher values -Wstrict-overflow=

GCC has moved on a lot since 7.1 and pngfix.c now compiles with just one warning using -Wstrict-overflow=5. The change includes a change to make this go away by performing the rearrangement GCC was using in the code:

i == ndigits-1

becomes:

i+1 == ndigits

i is initialized to ndigits and has been decremented at least once so this is fine.

Test, configure:

CFLAGS="-Wall -Wextra -Wno-maybe-uninitialized -Wstrict-overflow=5" \ ../configure --enable-werror make make cehck

Test, cmake:

cmake .. make make test