This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB 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++/12585] New: class name lookup wrong when in constructor


http://sourceware.org/bugzilla/show_bug.cgi?id=12585

           Summary: class name lookup wrong when in constructor
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: andre.poenitz@nokia.com


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

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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