https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55985

--- Comment #2 from Jonathan Leffler <jonathan.leffler at gmail dot com> ---
This problem has been mostly resolved in 5.3.0 (and quite possibly earlier):

$ gcc -O3 -Werror -Wall -g -std=c99   -c -o gccbug.o gccbug.c
gccbug.c: In function ‘updtypes’:
gccbug.c:20:18: error: ‘savtupstart’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
         tupstart += colsize;
                  ^
cc1: all warnings being treated as errors
make: *** [gccbug.o] Error 1
$ gcc  -Werror -Wall -g -std=c99 -c gccbug.c
gccbug.c: In function ‘updtypes’:
gccbug.c:28:22: error: ‘savtupstart’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
             tupstart = savtupstart;
                      ^
cc1: all warnings being treated as errors
rmk: error code 1
$ gcc --version
gcc (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$

These warnings are correctly identifying savtupstart (instead of tupstart) as
the uninitialized variable.  We can argue about the line that's identified in
the first invocation, but the main message is identifying the correct variable.

This test was conducted on the same machine referenced in the original bug
report; the version information from 'uname -a' hasn't changed.  The machine is
behind multiple layers of firewall and was last booted 'system boot  2015-08-23
21:35'.

The -v output for the non-optimized test was:

$ gcc -v -Werror -Wall -g -std=c99 -c gccbug.c
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.3.0/configure --prefix=/usr/gcc/v5.3.0
--with-as=/usr/gnu64/bin/as --with-ld=/usr/gnu64/bin/ld CC=/usr/bin/gcc
CXX=/usr/bin/g++ : (reconfigured) ../gcc-5.3.0/configure
--prefix=/usr/gcc/v5.3.0 --with-as=/usr/gnu64/bin/as
--with-ld=/usr/gnu64/bin/ld CC=/usr/bin/gcc CXX=/usr/bin/g++
Thread model: posix
gcc version 5.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-Werror' '-Wall' '-g' '-std=c99' '-c'
'-mtune=generic' '-march=x86-64'
 /work5/gcc/v5.3.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/cc1 -quiet
-v -iprefix /work5/gcc/v5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/
gccbug.c -quiet -dumpbase gccbug.c -mtune=generic -march=x86-64 -auxbase gccbug
-g -Werror -Wall -std=c99 -version -o /tmp/cc6Q2aEc.s
GNU C99 (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/work5/gcc/v5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory
"/work5/gcc/v5.3.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include"
ignoring duplicate directory
"/work5/gcc/v5.3.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed"
ignoring nonexistent directory
"/work5/gcc/v5.3.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /work5/gcc/v5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include
 /work5/gcc/v5.3.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed
 /usr/local/include
 /work5/gcc/v5.3.0/bin/../lib/gcc/../../include
 /usr/include
End of search list.
GNU C99 (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 981b21321de4233d53ef0e051a81a41f
gccbug.c: In function ‘updtypes’:
gccbug.c:28:22: error: ‘savtupstart’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
             tupstart = savtupstart;
                      ^
cc1: all warnings being treated as errors
$

If you require a test with 6.3.0 or a similar more modern version of GCC,
please let me know.

Reply via email to