|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page bug1556.cpp
This program is producing strange results. With one compiler I get a report that it has performed an illegal operation. With another compiler I get no output. What's going on? bug1556.cpp lint Output
--- Module: bug1556.cpp
_
return new int(n);
bug1556.cpp(5) : Warning 1556: 'new Type(integer)' is suspicious
Reference Manual Explanation
1556 'new Type(integer)' is suspicious -- A new expression had
the form new T(Integer) where type T has no constructor.
For example:
new int(10);
will draw this warning. The expression allocates an area
of storage large enough to hold one integer. It then
initializes that integer to the value 10. Could this have
been a botched attempt to allocate an array of 10
integers? Even if it was a deliberate attempt to allocate
and initialize a single integer, a casual inspection of
the code could easily lead a reader astray.
The warning is only given when the type T has no
constructor. If T has a constructor then either a
syntactic error will result because no constructor matches
the argument or a match will be found. In the latter case
no warning will or should be issued.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #1554 - May 2003