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
Duplicate. *** This bug has been marked as a duplicate of bug 8888 ***