Hi, Andreas Stieger wrote: > I am investigating a build warning->failure with 2.8 with > --enable-gcc-warnings: > > in lib/diffseq.h compareseq() the fxbest and bxbest variables seems to > be uninitialized in some code paths. This is from gcc 7 through 14. Was > thinking about initializing to -1 and OFFSEX_MAX... > > > [ 35s] gcc -fstrict-flex-arrays -Wall -Warith-conversion > -Wbad-function-cast -Wcast-align=strict -Wdate-time > -Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches > -Wduplicated-cond -Wextra -Wformat-signedness > -Wflex-array-member-not-at-end -Winit-self -Winvalid-pch -Wlogical-op > -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes > -Wmissing-variable-declarations -Wnested-externs -Wnull-dereference > -Wold-style-definition -Wopenmp-simd -Woverlength-strings -Wpacked > -Wpointer-arith -Wshadow -Wstack-protector -Wstrict-flex-arrays > -Wstrict-overflow -Wstrict-prototypes -Wsuggest-attribute=cold > -Wsuggest-attribute=const -Wsuggest-attribute=format > -Wsuggest-attribute=malloc -Wsuggest-attribute=noreturn > -Wsuggest-attribute=pure -Wsuggest-final-methods -Wsuggest-final-types > -Wsync-nand -Wtrampolines -Wuninitialized -Wunknown-pragmas > -Wunsafe-loop-optimizations -Wunused-macros -Wvariadic-macros > -Wvector-operation-performance -Wvla -Wwrite-strings -Warray-bounds=2 > -Wattribute-alias=2 -Wbidi-chars=any,ucn -Wformat-overflow=2 -Wformat=2 > -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 > -Wuse-after-free=3 -Wunused-const-variable=2 -Wvla-larger-than=4031 > -Wno-sign-compare -fdiagnostics-show-option -Werror -O2 -Wall > -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong > -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection > -Werror=return-type -flto=auto -g -flto=auto -o patch inp.o patch.o > pch.o safe.o util.o version.o merge.o ../lib/libpatch.a > [ 35s] In function 'diag', > [ 35s] inlined from 'compareseq' at ../lib/diffseq.h:515:7: > [ 35s] ../lib/diffseq.h:426:36: error: 'fxbest' may be used > uninitialized [-Werror=maybe-uninitialized] > [ 35s] 426 | part->ymid = fxybest - fxbest; > [ 35s] | ^ > [ 35s] ../lib/diffseq.h: In function 'compareseq': > [ 35s] ../lib/diffseq.h:387:32: note: 'fxbest' was declared here > [ 35s] 387 | OFFSET fxybest = -1, fxbest; > [ 35s] | ^ > [ 35s] In function 'diag', > [ 35s] inlined from 'compareseq' at ../lib/diffseq.h:515:7: > [ 35s] ../lib/diffseq.h:433:36: error: 'bxbest' may be used > uninitialized [-Werror=maybe-uninitialized] > [ 35s] 433 | part->ymid = bxybest - bxbest; > [ 35s] | ^ > [ 35s] ../lib/diffseq.h: In function 'compareseq': > [ 35s] ../lib/diffseq.h:405:40: note: 'bxbest' was declared here > [ 35s] 405 | OFFSET bxybest = OFFSET_MAX, bxbest; > [ 35s] | ^ > [ 35s] lto1: all warnings being treated as errors > [ 35s] make[3]: *** [/tmp/ccmbP17S.mk:5: > /tmp/ccLaMCeZ.ltrans1.ltrans.o] Error 1 > [ 35s] make[3]: *** Waiting for unfinished jobs...
diffseq.h contains the line # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" that should be sufficient for disabling these warnings. Alas, per GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106823> the warnings appear nevertheless. In other words, the GCC options -flto and -Werror are incompatible. Since -Werror is implied by patch/configure's --enable-gcc-warnings option, it means that you cannot use GCC's option -flto together with patch/configure's --enable-gcc-warnings option. You can use one or the other, but not both. Bruno
