[Bug bootstrap/50148] GCC fails to bootstrap with -O3 due to "may be used uninitialized" errors

matt at use dot net gcc-bugzilla@gcc.gnu.org
Tue Dec 18 17:27:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50148

--- Comment #6 from Matt Hargett <matt at use dot net> 2012-12-18 17:26:54 UTC ---
Applying the supplied patch reveals another issue underneath, which is a false
positive:

/work/mhargett/gcc-trunk-obj/./prev-gcc/xg++
-B/work/mhargett/gcc-trunk-obj/./prev-gcc/
-B/u/mhargett/x86_64-unknown-linux-gnu/bin/ -nostdinc++
-B/work/mhargett/gcc-trunk-obj/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-B/work/mhargett/gcc-trunk-obj/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
-I/work/mhargett/gcc-trunk-obj/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/work/mhargett/gcc-trunk-obj/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/work/mhargett/gcc-trunk/libstdc++-v3/libsupc++
-L/work/mhargett/gcc-trunk-obj/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-L/work/mhargett/gcc-trunk-obj/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
  -g -O2 -O3 -march=nocona -mtune=core2 -floop-block -floop-interchange
-floop-strip-mine -flto=jobserver -frandom-seed=1 -DIN_GCC   -fno-exceptions
-fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long
-Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common 
-DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -o gengtype \
        gengtype.o gengtype-lex.o gengtype-parse.o gengtype-state.o version.o
errors.o libcommon.a ../libcpp/libcpp.a ../libiberty/libiberty.a
../libdecnumber/libdecnumber.a ../libbacktrace/.libs/libbacktrace.a libcommon.a
../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a
../libiberty/libiberty.a ../libdecnumber/libdecnumber.a 
In file included from ../../gcc-trunk/libiberty/cp-demangle.c:876:0,
                 from :51:
../../gcc-trunk/libbacktrace/elf.c: In function ‘elf_add’:
../../gcc-trunk/libbacktrace/mmapio.c:98:14: error: ‘ehdr_view.len’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   if (munmap (const_cast.v, view->len) < 0)
              ^
In file included from ../../gcc-trunk/libiberty/cp-demangle.c:879:0,
                 from :51:
../../gcc-trunk/libbacktrace/elf.c:476:25: note: ‘ehdr_view.len’ was declared
here
   struct backtrace_view ehdr_view;
                         ^
In file included from ../../gcc-trunk/libiberty/cp-demangle.c:876:0,
                 from :51:
../../gcc-trunk/libbacktrace/mmapio.c:98:14: error: ‘ehdr_view.base’ may be
used uninitialized in this function [-Werror=maybe-uninitialized]
   if (munmap (const_cast.v, view->len) < 0)
              ^
In file included from ../../gcc-trunk/libiberty/cp-demangle.c:879:0,
                 from :51:
../../gcc-trunk/libbacktrace/elf.c:476:25: note: ‘ehdr_view.base’ was declared
here
   struct backtrace_view ehdr_view;
                         ^
In file included from ../../gcc-trunk/libiberty/cp-demangle.c:879:0,
                 from :51:
../../gcc-trunk/libbacktrace/elf.c:516:10: error: ‘ehdr_view.data’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   memcpy (&ehdr, ehdr_view.data, sizeof ehdr);
          ^
In file included from ../../gcc-trunk/libiberty/cp-demangle.c:879:0,
                 from :51:
../../gcc-trunk/libbacktrace/elf.c:476:25: note: ‘ehdr_view.data’ was declared
here
   struct backtrace_view ehdr_view;
                         ^
lto1: all warnings being treated as errors
make[4]: *** [/tmp/ccQGEpYR.ltrans15.ltrans.o] Error 1


in libbacktrace/elf.c, elf_add() calls backtrace_get_view(..., &ehdr_view).
ehdr_view isn't initialized. backtrace_get_view() will return 1 and leave
edhr_view uninitialized, but the potential uninitialized use of ehdr_view is
guarded in get_elf() with a 'goto fail'. Therefore, the uninitialized ehdr_view
would never get to backtrace_release_view().

Let me know if I should file a separate bug for this.



More information about the Gcc-bugs mailing list