Click on image to see enlargment

PC-lint/FlexeLint Output | Reference Manual Explanation | Home


1    #include <stdio.h>
3    class Bird {  };
4    class Turkey : public Bird
5        { public: Turkey() { printf("Buy turkey\n"); }
6          virtual ~Turkey(){ printf("Eat turkey\n"); } };
8    void dinner( Bird * p ) { delete p; }
10   int main()     // Thanksgiving Day
11       {
12       Turkey *p = new Turkey;
13       dinner(p);
14       return 0;
15       }

In this example the printout shows that on Thanksgiving Day a turkey was purchased but it was never eaten in spite of the fact that the bird was taken to dinner. What went wrong?

bug1510.cpp lint Output

--- Module:   bug1510.cpp
      virtual ~Turkey(){ printf("Eat turkey\n"); } };
bug1510.cpp(6) : Warning 1510: base class 'Bird' has no destructor

Reference Manual Explanation

1510   base class 'Name' has no destructor  -- The indicated class is a
       base class for some derived class that has a destructor.  The
       base class does not have a destructor.  Is this a mistake?  The
       difficulty that you may encounter is this; if you represent (and
       manipulate) a heterogeneous collection of possibly derived
       objects via a pointer to the base class then you will need a
       virtual base class destructor to invoke the derived class
       destructor.  [13, 4]

If you have comments or questions about this bug, please post them to our   Discussion Forum

Previous Bug - Bug #416 - October 2005

[ new ] Use our Interactive Demo to Run FlexeLint on our Bugs of the Month

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright 2006, Gimpel Software, All rights reserved.