This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Compiler bug with nested classes?


Hello,

I am running egcs-1.0.1 on Solaris x86 (5.5). I am having a problem with the
compiler: it is calling a pure virtual function. Here is a code fragment:

*** START FRAG ***

class ProjectSelector : public Form
{
  public:

    // The following structures may be used to sort displayed projects
    
    struct SortCompare
    {
        virtual ~SortCompare() {} ;
        virtual bool operator ()(const Project &p1, const Project &p2) const = 0 ;
    } ;

    struct OrigDateCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.originated() > p2.originated() ; }
    } ;
    
    struct DueDateCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.due() > p2.due() ; }
    } ;
    
    struct NameCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.getName() < p2.getName() ; }
    } ;
    
    struct LeadCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.getLead() < p2.getLead() ; }
    } ;
    
    struct DescriptionCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.getDescription() < p2.getDescription() ; }
    } ;
    
    struct BillingNotesCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.getBillingNotes() < p2.getBillingNotes() ; }
    } ;
    
    struct OrigEstCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.getOriginalEstimate() > p2.getOriginalEstimate() ; }
    } ;
    
    struct RevisedEstCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.getRevisedEstimate() > p2.getRevisedEstimate() ; }
    } ;
    
    struct PriorityCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const { return p1.getPriority() > p2.getPriority() ; }
    } ;

    struct ChargeCompare : public SortCompare
    {
        bool operator ()(const Project &p1, const Project &p2) const ;
    } ;

    bool sortProjects(const SortCompare &sc) ;
        // Sorts projects

    // Lots of other stuff...
} ;

...

bool ProjectSelector::sortProjects(const SortCompare &sc)
{
   // *** PROBLEM OCCURS HERE ***

    // Sort
    ptracker.sort(sc) ; // ptracker is a data member of ProjectSelector -> list<Project>

    // Other stuff...
}

...

ProjectSelector psel ;
ProjectSelector::DescriptionCompare comp ;

psel.sortProjects(comp) ;

*** END FRAG ***

The compiler compiles the code just fine, but when sortProjects is called, the program
exits and the message:

pure virtual method called

Dan
-- 
Daniel J. Bernstein
Partner, Computer Science Services Group, LLC

E: dan@cssgroup.com
V: 316.269.9090
F: 316.269.2650
W: http://www2.southwind.net/~css

Obligatory quote:

"A lot has been said about politics; some of it complimentary,
but most of it accurate."

    -- Eric Idle



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]