Subject: bug#78019: LTO build fails with diffutils 3.12

From: Christian Hesse <[email-masked]>
Date: Wed, 23 Apr 2025 19:56:17 +0200

Hello everybody,

I am building diffutils 3.12 in a clean build environment for Arch Linux. That
fails when building with link time optimization is enabled:

In function 'diag',
    inlined from 'compareseq' at ../lib/diffseq.h:515:7:
../lib/diffseq.h:426:36: error: 'fxbest' may be used uninitialized [-Werror=maybe-uninitialized]
  426 |               part->ymid = fxybest - fxbest;
      |                                    ^
../lib/diffseq.h: In function 'compareseq':
../lib/diffseq.h:387:32: note: 'fxbest' was declared here
  387 |           OFFSET fxybest = -1, fxbest;
      |                                ^
In function 'diag',
    inlined from 'compareseq' at ../lib/diffseq.h:515:7:
../lib/diffseq.h:433:36: error: 'bxbest' may be used uninitialized [-Werror=maybe-uninitialized]
  433 |               part->ymid = bxybest - bxbest;
      |                                    ^
../lib/diffseq.h: In function 'compareseq':
../lib/diffseq.h:405:40: note: 'bxbest' was declared here
  405 |           OFFSET bxybest = OFFSET_MAX, bxbest;
      |                                        ^
sdiff.c: In function 'edit':
sdiff.c:957:11: error: 'cmd1' may be used uninitialized [-Werror=maybe-uninitialized]
  957 |           switch (cmd1)
      |           ^
sdiff.c:861:11: note: 'cmd1' was declared here
  861 |       int cmd1;
      |           ^
lto1: all warnings being treated as errors

The build succeed as soon as I disable link time optimization. Would be nice
to have a fix for this to reenable lto. Let me know if I can provide more
information on this. Thanks!
-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Best regards             my address:    */=0;b=c[a++];)
putchar(b-1/(/*    Chris            cc -ox -xc - && ./x    */b/42*2-3)*42);}