[Bug c++/9688] New: gdb core dump c++ virtual inheritance
sirlore at gmail dot com
sourceware-bugzilla@sourceware.org
Sat Dec 27 15:14:00 GMT 2008
Gdb core dumps on virtual inheritance, ONLY when base class implementation and
specification is separated. Note that base class specification is in file
`base.h` a implementation is in `base.cpp`.
Release:
GNU gdb 6.8-debian
Environment:
Linux 2.6.26-1-686 #1 SMP Thu Oct 9 15:18:09 UTC 2008 i686 GNU/Linux
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1)
How-To-Repeat:
///FILE base.h
#ifndef __BASE_H__
#define __BASE_H__
class Base {
public:
Base();
virtual ~Base();
virtual void run();
};
#endif
///FILE base.cpp
#include "base.h"
#include <iostream>
Base::Base()
{ std::cout << "base\n"; }
Base::~Base()
{ }
void Base::run()
{ }
///FILE gdb_bug.cpp
#include "base.h"
class Derived1 : virtual public Base{
protected:
int i;
public:
Derived1(){};
};
class Derived2 : public Derived1 {
public:
Derived2(){};
~Derived2(){};
};
class Derived3 : virtual public Base {
public:
Derived3(){};
~Derived3(){};
};
class Bug : public Derived2, public Derived3{
public:
Bug(){};
~Bug(){};
virtual void run(){};
};
int main(int argc, char *argv[])
{
Bug b;
int a =2; // breakpoint here. Command `print b` makes gdb SEG FAULT
return 0;
}
//-------------------------------
g++ -O0 -g3 base.cpp gdb_bug.cpp -o bug
gdb ./bug
break main
run
n
print b
************* SEGMENTAION FAULT ************
--
Summary: gdb core dump c++ virtual inheritance
Product: gdb
Version: 6.8
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at sourceware dot org
ReportedBy: sirlore at gmail dot com
CC: gdb-prs at sourceware dot org
http://sourceware.org/bugzilla/show_bug.cgi?id=9688
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the Gdb-prs
mailing list