This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/67315] [4.9 Regression] Strange 'this' pointer behavior when calling virtual function with different optimization attributes.


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-08-22
      Known to work|                            |4.8.4, 5.2.0, 6.0
            Summary|Strange 'this' pointer      |[4.9 Regression] Strange
                   |behavior when calling       |'this' pointer behavior
                   |virtual function with       |when calling virtual
                   |different optimization      |function with different
                   |attributes.                 |optimization attributes.
     Ever confirmed|0                           |1
      Known to fail|                            |4.9.3

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I can reproduce this with any 4.9.x release, but not with 5.x or trunk.

Doesn't happen for x86_64 only 32-bit. Only -O2 is needed.

$ ~/gcc/4.9.3/bin/g++ v.cc -Wall -O2 -m32
$ ./a.out
Init 0x8218a10 
m_test = 4
Calling test11 0xf76a94ec
Calling test21 0xf76a94ec
$ valgrind ./a.out
==12566== Memcheck, a memory error detector
==12566== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==12566== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==12566== Command: ./a.out
==12566== 
Init 0x41c7a58 
m_test = 4
==12566== Conditional jump or move depends on uninitialised value(s)
==12566==    at 0x465C6B0C: vfprintf (in /usr/lib/libc-2.21.so)
==12566==    by 0x465CF455: printf (in /usr/lib/libc-2.21.so)
==12566==    by 0x8048630: Test::test11() (in /tmp/a.out)
==12566==    by 0x8048696: Test::init() (in /tmp/a.out)
==12566==    by 0x80484F3: main (in /tmp/a.out)
==12566== 
Calling test11 (nil)
==12566== Conditional jump or move depends on uninitialised value(s)
==12566==    at 0x465C6B0C: vfprintf (in /usr/lib/libc-2.21.so)
==12566==    by 0x465CF455: printf (in /usr/lib/libc-2.21.so)
==12566==    by 0x8048610: ITest2::test21() (in /tmp/a.out)
==12566==    by 0x80486C6: Test::init() (in /tmp/a.out)
==12566==    by 0x80484F3: main (in /tmp/a.out)
==12566== 
Calling test21 (nil)
==12566== 
==12566== HEAP SUMMARY:
==12566==     in use at exit: 18,956 bytes in 2 blocks
==12566==   total heap usage: 2 allocs, 0 frees, 18,956 bytes allocated
==12566== 
==12566== LEAK SUMMARY:
==12566==    definitely lost: 12 bytes in 1 blocks
==12566==    indirectly lost: 0 bytes in 0 blocks
==12566==      possibly lost: 0 bytes in 0 blocks
==12566==    still reachable: 18,944 bytes in 1 blocks
==12566==         suppressed: 0 bytes in 0 blocks
==12566== Rerun with --leak-check=full to see details of leaked memory
==12566== 
==12566== For counts of detected and suppressed errors, rerun with: -v
==12566== Use --track-origins=yes to see where uninitialised values come from
==12566== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]