[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bus error at virtual method call
From: |
Paul van Hagen |
Subject: |
bus error at virtual method call |
Date: |
30 Sep 2004 14:03:01 -0700 |
Hello,
I have built an executable on a Solaris 2.8 (Sparc) workstation with gnu g++
2.95.3.
However, at execution it crashes with a SIGBUS error.
I have used the -O3 level optimizer. The same code runs fine on a Linux
environment, same code, same compiler, different hardware.
I have narrowed it down to a call to a private virtual method that is called
from a public base class method, such as in:
class A
{
public:
A() { }
virtual ~A() { }
void doSomething(int i)
{
// some preparation code using i
doSomething(); // -> bus error at this call !
}
private:
virtual void doSomething() { };
};
class B
{
// ... ctor/dtor
private:
virtual void doSomething()
{
// never gets here!
}
};
When I compile for debugging (-DDEBUG -g) the problem disappears.
Is there a way to circumvent this problem by refactoring, lowering O level
or perhaps use other compilation flags.
Thx
Paul
- bus error at virtual method call,
Paul van Hagen <=