Bug with virtual base classes an exceptions.
Kevin Atkinson
kevinatk@home.com
Sun Feb 27 21:35:00 GMT 2000
The following code aborts on the assertion with gcc 2.95.1 and 2.96
20000214 but NOT with egcs 1.1.2:
#include <iostream>
#include <exception>
#include <cassert>
struct MyException : virtual public exception
{
int value;
MyException(int v) : value(v) {}
~MyException() {assert(value == 10);}
};
int main() {
try {
throw MyException(10);
} catch (exception & e) {
cerr << e.what() << endl;
}
}
It will not abort if when the base class is non virtual or
} catch (exception & e) {
is changed to
} catch (MyException & e) {
This creates a problem with my aspell package
( http://aspell.sourceforge.net ) as the exception heritage
used virtual base classes. If you want to see the bug in action try
installing aspell compiled with the gcc 2.95.1 and type in this
src/aspell -a --master=dkl
And you will get something like this.
Sorry, I can't read the file "/usr/local/lib/aspell/dkl".
I get this problem on intel-linux, sparc-solaris, and dec-alpha.
---
Kevin Atkinson
kevinatk@home.com
http://metalab.unc.edu/kevina/
More information about the Gcc-bugs
mailing list