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 debug/17799] New: Non-optimizing compile loses 'this'


With the attached test case, compile with

  g++ -g z.cc -lpthread

(gdb) b 'Foo::bar()'
Breakpoint 1 at 0x804850d: file z.c, line 34.
(gdb) run
Starting program: /home/rth/x/a.out
[Thread debugging using libthread_db enabled]
[New Thread -1220950400 (LWP 31166)]
[New Thread -1220953168 (LWP 31169)]
[Switching to Thread -1220953168 (LWP 31169)]
 
Breakpoint 1, Foo::bar (this=0x80498c0) at z.c:34
34        if (_y!=MODEB)
Current language:  auto; currently c++
(gdb) p this
$1 = (Foo * const) 0x80498c0
(gdb) n
38        return true;
(gdb) p this
$2 = (Foo * const) 0x0


While it's completely understandable for variables to be optimized away
with optimization, it's uncool for it to happen when compiling at -O0.

I'm pretty sure this due to the fact that 'this' is marked DECL_ARTIFICIAL
by the C++ front end, and DECL_ARTIFICIAL variables are allocated to 
registers rather than on the stack.

This is a regression from gcc 3.4.

-- 
           Summary: Non-optimizing compile loses 'this'
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rth at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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