Click on image to see enlargment

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

            bug1511.cpp

1    #include <stdio.h>
2
3    typedef const char *cSTR;
4
5    struct president
6        { cSTR fool() const { return "none"; } };
7    struct OH : public president
8        { cSTR fool() const { return "all"; } };
9
10   cSTR assume_office( const president * p )
11       { return p->fool(); }
12
13   int main()
14       {
15       OH *p = new OH;
16       printf( "we will fool %s of the people.\n",
17               assume_office( p ) );
18       return 0;
19       }

A new Office Holder OH assumes power hoping to fool all of the people but instead fools no one. What is his mistake?


bug1511.cpp lint Output

--- Module:   bug1511.cpp (C++)
                        _
    { cSTR fool() const { return "all"; } };
bug1511.cpp(8) : Warning 1511: Member hides non-virtual member
    'president::fool(void) const' (line 6)
            _
    return 0;
bug1511.cpp(18) : Warning 429: Custodial pointer 'p' (line 15) has not been
    freed or returned

Reference Manual Explanation


1511   Member hides non-virtual member 'Symbol' (Location)  -- The named
       member of a derived class hides a similarly named member of a
       base class.  Moreover, the base class member is not virtual.  Is
       this a mistake?  Was the base member supposed to have been
       declared virtual?  By unnecessarily using the same name,
       confusion could be created.

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

Previous Bug - Bug #750 - January 2006

[ 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.