I have the problem with gdb 7.6 and g++ 4.8.3. I have the following 3 files
main.h
class A {
public:
class B {
public:
virtual ~B();
virtual void f();
int abc;
};
};
b.cpp
#include "main.h"
A::B::~B() {}
void A::B::f() {}
main.cpp
#include "main.h"
int main()
{
int a=0;
A::B x;
A::B *y = &x;
a = 10;
return a;
}
Then
>> g++ main.cpp b.cpp -o main -g
>> gdb ./main
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/gdb/main...done.
(gdb) b 8
Breakpoint 1 at 0x400654: file main.cpp, line 8.
(gdb) r
Starting program: /tmp/gdb/main
Breakpoint 1, main () at main.cpp:8
8 a = 10;
(gdb) p *y
$1 = <incomplete type>
We do not have the problem if
- the definition of those methods is in main.h.
- the methods are virtual.
Is this a known issue? How to workaround the problem?