From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6086 invoked by alias); 19 Mar 2014 12:09:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 6064 invoked by uid 48); 19 Mar 2014 12:09:28 -0000 From: "andris.pavenis at iki dot fi" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60585] New: Virtual function related memory access errors with multiple virtual inheritance Date: Wed, 19 Mar 2014 12:09:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: andris.pavenis at iki dot fi X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg01727.txt.bz2 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)