Bug 12585 - class name lookup wrong when in constructor
Summary: class name lookup wrong when in constructor
Status: RESOLVED DUPLICATE of bug 8888
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-15 09:20 UTC by Andre'
Modified: 2012-11-21 21:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre' 2011-03-15 09:20:44 UTC
gdb mistakes the name 'foo' within the constructor of a class 'foo' for a reference to the constructor itself, not as the class name. This makes it
impossible to refer to the type 'foo' in such a location

---------------- snip ----------------
#!/bin/sh

g++ -g -xc++ - <<EOF
struct foo {
    foo() {   // does not happen with s/foo/int bar/ here
        i = 0;
    }
    int i;
};

int main()
{
    foo f;
    return f.i;
}
EOF 

gdb -ex 'set confirm off' \
    -ex 'file a.out' \
    -ex 'start' \
    -ex 'b 4' \
    -ex 'c' \
    -ex 'p this' \
    -ex 'p (foo * const) 0xbfffe520' \
    -ex 'p (int * const) 0xbfffe520' \
    -ex 'p foo ' \
    -ex 'q'
---------------- snip ----------------


produces:

GNU gdb (GDB) 7.2 [...]
This GDB was configured as "i686-pc-linux-gnu". [...]
Temporary breakpoint 1, main () at <stdin>:10
$1 = (foo * const) 0xbfffefdc
A syntax error in expression, near `const) 0xbfffe520'.
$2 = (int * const) 0xbfffe520
$3 = {void (foo *)} 0x80484b0 <foo::foo()>

after replacing the constructor with an ordinary member function int bar()
the result is

$1 = (foo * const) 0xbfffefdc
$2 = (foo * const) 0xbfffe520
$3 = (int * const) 0xbfffe520
Comment 1 Tom Tromey 2012-11-21 21:37:23 UTC
Duplicate.

*** This bug has been marked as a duplicate of bug 8888 ***