Click on image to see enlargment

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

            bug1752.cpp

1    #include <stdio.h>
2
3    struct Exception { virtual int kind() { return 0; } };
4    struct NoArgs : public Exception
5                     { int kind() { return 1; } };
6    NoArgs noargs;
7    int main( int argc )
8        {
9        try
10           {
11           if( argc < 2 ) throw noargs;
12           }
13       catch( Exception e )
14           {
15           printf( "%d\n", e.kind() );
16           }
17       return 0;
18       }

Our programmer is attempting to catch illegal input but his report is not quite what he wanted. What's going wrong?


bug1752.cpp lint Output

--- Module:   bug1752.cpp
                       _
    catch( Exception e )
bug1752.cpp(13) : Info 1752: catch parameter is not a reference

--- Global Wrap-up

Info 729: Symbol 'noargs' (line 6, file bug1752.cpp) not explicitly initialized

Reference Manual Explanation

  
1752  catch parameter is not a reference  -- This message is issued for every catch
      parameter that is not a reference and is not numeric.  The problem with pointers is
      a problem of ownership and delete responsibilities; the problem with a non-ref
      object is the problem of slicing away derivedness  [23, Item 13].

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

Previous Bug - Bug #613 - July 2004

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