PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page
1 #include <string.h>
2
3 class X
4 {
5 int *p;
6 public:
7 X()
8 { p = new int[20]; }
9 void init()
10 { if(p) memset( p, 20, 'a' ); }
11 ~X()
12 { delete[] p; }
13 };
There is a significant problem with this class that would make it behave irrationally. Can you find it?
--- Module: bug669.cpp
_
{ p = new int[20]; }
bug669.cpp(8) : Info 1732: new in constructor for class X which has no
assignment operator
bug669.cpp(8) : Info 1733: new in constructor for class X which has no
copy constructor
_
{ if(p) memset( p, 20, 'a' ); }
bug669.cpp(10) : Warning 669: Possible data overrun for function
memset(void *, int, unsigned int), argument 3 exceeds argument 1
--- Wrap-up for Module: bug669.cpp
Info 753: local class X (line 3, file bug669.cpp) not referenced
669 Possible data overrun for function Symbol, argument Integer
exceeds argument Integer -- This message is for data transfer
functions such as memcpy, strcpy, fgets, etc. when the size
indicated by the first cited argument (or arguments) can possibly
exceed the size of the buffer area cited by the second. The
message may also be issued for user functions via the -function
option. See Function Mimicry and Value Tracking.
Previous Bug - Bug #578 - October 1997
Next Bug - Bug # 671 - December 1997