[C++-sig] Bug: Pyste and pure virtual functions.

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Sat Aug 16 05:32:30 CEST 2003


>>>>> "N" == nicodemus  <nicodemus at globalite.com.br> writes:

    N> Hi Prabhu!  Prabhu Ramachandran wrote:

    >> 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(); }
[snip]

    N> Hi Prabhu!

    N> My first version was like yours, but the missing return
    N> generates warnings with Intel 6, so I added it. I didn't know
    N> it would generate an error in gcc, thought 8/ Any suggestions?

Well, it will generate errors under Intel 6 also if the returned class
has no nullary constructor.  I'm not sure if 'return unsigned int();'
will also compile correctly.

One alternative is that for standard types (int, float etc.) the
brackets are removed but the return value is there.  For
classes/structures that are returned we add the brackets or
alternatively dont return anything and live with the warnings.  It
would be nice if there were a better way.

cheers,
prabhu





More information about the Cplusplus-sig mailing list