[C++-sig] Bug: Pyste and pure virtual functions.
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Fri Aug 15 18:18:43 CEST 2003
hi,
Just found a bug with Pyste's generation of the default wrapper
function for pure virtual functions. Here is a simple example.
// ------------- simple.hpp -------------------------
class A {
public:
virtual unsigned int f() = 0;
};
// --------------------------------------------------
Wrapping this with the following fails.
simple = Class('A', 'simple.hpp')
This is because Pyste generates the following code:
unsigned int default_f() {
PyErr_SetString(PyExc_RuntimeError, "pure virtual function called");
throw_error_already_set();
return unsigned int();
}
Which generates a parse error. Additionally returning some_class()
also requires that the class have a nullary constructor which might
not always be available. I find that generating this code instead
works fine under gcc 2.95.4:
unsigned int default_f() {
PyErr_SetString(PyExc_RuntimeError, "pure virtual function called");
throw error_already_set();
}
This compiles cleanly (with no warnings) for me but is it valid C++
and will it work properly under all compilers? If this is OK I'll
send in a patch to fix this. If not, are there other ways to handle
this correctly?
Thanks!
cheers,
prabhu
More information about the Cplusplus-sig
mailing list