http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60585
Bug ID: 60585 Summary: Virtual function related memory access errors with multiple virtual inheritance Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: andris.pavenis at iki dot fi Created attachment 32392 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32392&action=edit Simplified C++ test example The attached reduced example causes valgrind to complain about access to uninitialized value when built with gcc-4.9.0 20140318 on Linux (both i86 and x86_64, included output is from 32 bit version): andpav@andris-HP-Z230:~/Tests/2014-03-18$ g++-4.9 -O2 -Wall -Wextra virtual.cpp andpav@andris-HP-Z230:~/Tests/2014-03-18$ valgrind ./a.out ==10812== Memcheck, a memory error detector ==10812== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==10812== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info ==10812== Command: ./a.out ==10812== ==10812== Use of uninitialised value of size 4 ==10812== at 0x80484C6: virtual thunk to F::f() const (in /home/andpav/Tests/2014-03-18/a.out) ==10812== by 0x8048379: main (in /home/andpav/Tests/2014-03-18/a.out) ==10812== ==10812== ==10812== HEAP SUMMARY: ==10812== in use at exit: 0 bytes in 0 blocks ==10812== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==10812== ==10812== All heap blocks were freed -- no leaks are possible ==10812== ==10812== For counts of detected and suppressed errors, rerun with: -v ==10812== Use --track-origins=yes to see where uninitialised values come from ==10812== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) andpav@andris-HP-Z230:~/Tests/2014-03-18$ g++-4.9 -v Using built-in specs. COLLECT_GCC=g++-4.9 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.9.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: ../gcc-4.9-20140318/configure --program-suffix=-4.9 --enable-languages=c,c++ --enable-lto Thread model: posix gcc version 4.9.0 20140318 (experimental) (GCC) There are also ocasional crashes (SIGSEGV) in real software from which the reduced example has been created. Also reproduced with gcc-4.8 (Fedora 20 x86_64 and Ubuntu 13.10 i686) and gcc-4.7 (Ubuntu-13.10 i686). Does not happen with gcc-4.6 (Ubuntu 12.04) Also specifying -fno-inline-small-functions together with -O2 or -O3 for affected gcc versions make the problem not happen (both reduced example and real software)