This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Compiler bug with nested classes?
- To: egcs-bugs at cygnus dot com, dan at halley dot cssgroup dot com
- Subject: Compiler bug with nested classes?
- From: "D. Bernstein" <dan at cssgroup dot com>
- Date: Fri, 27 Feb 1998 11:02:03 -0600
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