msg.txt
资源名称:pclint.rar [点击查看]
上传用户:filter2008
上传日期:2010-03-12
资源大小:2959k
文件大小:315k
源码类别:
编辑器/阅读器
开发平台:
C/C++
- of a structure (or union) is equal to the maximum
- alignment of any of its members. When an array of
- structures is allocated, the compiler ensures that each
- structure is allocated at an address with the proper
- alignment. This will require padding if the size of the
- structure is not an even multiple of its maximum
- alignment. For example:
- struct A { int n; char ch; } a[10];
- Assuming the size and alignment of int is 4 then the size
- of each struct is 5 but its alignment is 4. As a result
- each struct in the array will be padded with 3 bytes.
- Alignment can vary with the compiler and the machine. If
- binary data is to be shared by separately compiled
- modules, it is safer to make sure that all shared
- structures and unions are explicitly padded.
- 960 Violates MISRA Required Rule Name, String -- MISRA is the
- "Guidelines for the use of the C Language in Vehicle Based
- Software". You may disable individual rules to your
- taste by using the Rule number in an esym option. For
- example:
- -esym( 960, 75, 8? )
- will suppress MISRA rules 75 and any of those between 80
- and 89 inclusive that are issued as the result of a
- message 960. See [10] for information on the MISRA
- guidelines.
- 961 Violates MISRA Advisory Rule Name, String -- This message
- is issued when a violation of the MISRA advisory
- guidelines is detected. See also Message 960.
- 964 Header file FileName not directly used in module String
- -- The given header file was not used in the given module,
- however it, itself, included a header file (possibly
- indirectly) that was used. An example of this is os2.h
- that is an umbrella header serving only to include other
- headers. Compare this message with 766. See also the
- discussion in Section 11.8.1 Unused Headers.
- 966 Indirectly included header file 'FileName' not used in
- module 'String' -- The header file given by FileName was
- unused directly or indirectly in a given module outside of
- its group. It was not, however, directly included by the
- module and so may not easily be excluded without
- disturbing the header including it. Since this header may
- be included in other places caution is advised. This
- message is a weaker version of 766. See the discussion
- in Section 11.8.1 Unused Headers. See also message 964.
- 970 Use of modifier or type 'Name' outside of a typedef --
- Some standards require the use of type names (defined in
- typedef's) in preference to raw names used within the text
- of the program. For example they may want you to use
- INT32 rather than int where INT32 is defined as:
- typedef int INT32;
- This message is normally issued for the standard intrinsic
- types: bool, char, wchar_t, int, float, double, and for
- modifiers unsigned, signed, short and long. You may
- enable this message and then suppress the message for
- individual types to obtain special effects. For example
- the following will enable the message for all but bool.
- +e970 -esym(970,bool)
- 971 Use of 'char' without 'signed' or 'unsigned' -- The
- 'char' type was specified without an explicit modifier to
- indicate whether the char was signed or unsigned. The
- plain char type can be regarded by the compiler as
- identifying a signed or an unsigned quantity, whichever is
- more efficient to implement. Because of this ambiguity,
- some standards do not like the use of char without an
- explicit modifier to indicate its signedness.
- 973 Unary operator in macro 'Symbol' not parenthesized -- A
- unary operator appearing in an expression-like macro was
- found to be not parenthesized. For example:
- #define N -1
- The user may prefer to parenthesize such things as:
- #define N (-1)
- This has been placed in the elective note category because
- we cannot find an instance when this really produces a
- problem. The important case of unparenthesized binary
- operators is covered with message 773.
- 17.7 C++ Syntax Errors
- 1001 Scope 'Name' must be a struct or class name -- In an
- expression of the form X::Y, X must be a class name.
- [11 section 10.4]
- 1002 'this' must be used in class member function -- The
- keyword this refers to the class being passed implicitly
- to a member function. It is invalid outside a class
- member function. [11 section 5.1]
- 1003 'this' may not be used in a static member function -- A
- static member function receives no this pointer. [11
- section 9.4]
- 1004 Expected a pointer to member after .* or ->* -- The .*
- and ->* operators require pointer to members on the right
- hand side. [11 section 5.5]
- 1005 Destructor declaration requires class -- While expecting
- a declaration a '~' character was encountered. This was
- presumed to be the start of a destructor. However no
- class was specified. [11 section 12.4]
- 1006 Language feature 'String' not supported -- The indicated
- feature, while not supported in the current version, will
- hopefully be supported in future versions of the product.
- 1007 Pure specifier for function 'Symbol' requires a virtual
- function -- An '=' was found after a declaration. Was
- this the start of a pure specifier? The declaration was
- not that of a member function, which it must be. Also,
- the member function should be virtual. [11 section 10.3]
- 1008 Expected '0' to follow '=', text ignored -- Some
- nonstandard extensions to C++ allow integers to follow '='
- for declarations of member functions. If you are using
- such extensions simply suppress this message. If only
- library headers are using this extension use -elib(1008).
- [11 section 10.3]
- 1009 operator String not redefinable -- The cited operator,
- one of '.*', '?', '::' or '.', may not be overloaded.
- [11 section 13.4]
- 1010 Expected a type or an operator -- Following the keyword
- operator the parser expected either an operator (including
- new, delete, (), [], comma) or a type. [11 sections 13.4
- and 12.3.2]
- 1011 Conversion Type Name too long -- An upper limit of 50
- characters has been reached on a conversion type name.
- 1012 Type not needed before 'operator type' -- The return type
- of a function introduced with 'operator Type' is Type and
- may not be preceded with the same or any other Type. [11
- section 12.3.2]
- 1013 Symbol 'Name' not a member of class 'Name' -- The second
- operand of a scope operator or a '.' or '->' operator is
- not a member of the class (struct or union) expressed or
- implied by the left hand operand. [11 section 3.2]
- 1014 Explicit storage class not needed for member function
- 'Symbol' -- An explicit Symbol storage class such as
- extern or static was given in a separate definition of a
- class member. The storage class is effectively defined by
- its appearance within the class and may not be restated at
- definition time.
- 1015 Symbol 'Name' not found in class -- In an expression of
- the form X::Y, Y must be a member of X or of a public or
- protected base class of X. [11 section 10.4]
- 1016 Symbol 'Symbol' is supposed to denote a class -- In a
- base-specifier an identifier is supposed to specify a base
- class. However, the identifier was not previously
- declared in this module. [11 section 10]
- 1017 conflicting access-specifier 'String' -- Two different
- access specifiers were given in a simple base-specifier.
- [11 section 10]
- 1018 Expected a type after 'new' -- In an expression involving
- new, a type is expected after possibly processing a
- placement. None was found. [11 section 5.3.3]
- 1019 Could not find match for function 'Symbol(String)' -- In
- attempting to find a match between a set of overloaded
- functions or operators (name given as Symbol) and an
- actual argument list (provided as String) no match could
- be found. [11 section 13.2]
- 1022 Function: 'String' must be a class member -- There are
- four operators not to be defined except as class members.
- These are:
- = () [] ->
- The parameter String indicates which it is. [11 sections
- 13.4.3 and 13.4.6]
- 1023 Call 'String(String)' is ambiguous; candidates: 'String'
- -- A call to an overloaded function or operator is
- ambiguous. The candidates of choice are provided in the
- message. [11 section 13.2]
- 1024 No function has same argument count as 'Name' -- A call
- to an overloaded function could not be resolved
- successfully because no function is declared with the same
- number of arguments as in the call. [11 section 13.2]
- 1025 No function matches invocation 'Name' on arg no. Integer
- -- A call to an overloaded function could not be resolved
- because each declared function has a type incompatibility
- with the indicated argument. [11 section 13.2]
- 1026 Undominated function 'String' does not dominate 'String'
- on call to 'String' -- A call to an overloaded function
- could not be resolved because no one function dominates
- all others. This is a subtle issue in the overload
- resolution process. The selected function must be
- strictly better than any non-selected function in at least
- one argument. [11 section 13.2]
- 1027 Non-consecutive default arguments in function 'String',
- assumed 0 -- Default arguments need to be consecutive.
- For example
- void f(int i=0, int j, int k=0);
- is illegal. [11 section 8.2.6]
- 1028 Last argument not default in first instance of function
- 'String', assumed 0 -- If any argument of a function is
- given a default value then all subsequent arguments need
- to be given a default value. [11 section 8.2.6]
- 1029 Default argument repeated in function 'String' -- A
- default value for a given argument for a given function
- should only be given once. [11 section 8.2.6]
- 1030 Not all arguments after arg no. Integer are default in
- function 'String' -- An argument that has a default value
- must either be followed by another argument that has a
- default value, or must be the last argument. [11 section 8.2.6]
- 1031 Local variable 'Symbol' used in default argument
- expression -- Default values for arguments may not use
- local variables. [11 section 8.2.6]
- 1032 Member 'String' cannot be called without object -- There
- was an attempt to call a non-static member function
- without specifying or implying an object that could serve
- as the basis for the this pointer. If the member name is
- known at compile time it will be printed with the message.
- [11 section 5.24]
- 1033 Static member functions cannot be virtual -- You may not
- declare a static member function virtual. [11 section 10.2]
- 1034 Static member 'Symbol' is global and cannot be redefined
- -- This can come as a surprise to the novice C++
- programmer. The word 'static' within a class definition
- is used to describe a member that is alone and apart from
- any one object of a class. But such a member has program
- scope not file scope. The word 'static' outside a class
- definition implies file scope not program scope. [11
- section 9.4]
- 1035 Non-static member 'Symbol' cannot initialize a default
- argument -- A default argument cannot be initialized from
- a class member unless an instantiation of the class is
- provided. [11 section 8.2.6]
- 1036 ambiguous reference to constructor; candidates: 'String'
- -- There is more than one constructor that can be used to
- make a desired conversion. [11 section 12.3.2]
- 1037 ambiguous reference to conversion function; candidates:
- 'String' -- There is more than one conversion function
- (of the form operator type () ) that will perform a
- desired conversion. [11 section 12.3.2]
- 1038 type 'Name' not found, nested type 'Name::String' assumed
- -- We have found what appears to be a reference to a type
- but no such type is in scope. We have, however, been able
- to locate a type buried within another class. Is this
- what the user intended? If this is what is intended, use
- full scoping. If your compiler doesn't support the
- scoping, suppress with -esym. [11 section 3.2]
- 1039 Symbol 'Symbol' is not a member of class 'String' -- In a
- declaration for the symbol X::Y, Y was not previously
- established as a member of X. [11 section 10.4]
- 1040 Symbol 'Symbol' is not a legal declaration within class
- 'String' -- A declaration of the symbol X::Y appears
- within a class definition (other than for class X). It is
- not a friend declaration. Therefore it is in error.
- 1041 Can't declare 'String', assumed 'operator String' -- This
- message can be given with String equal to new or delete.
- Each 'String' in this message has the same value. A
- common mistake with beginning C++ programmers is to
- declare (and/or define) new when they mean to define opera
- tor new. We presume this was what was intended.
- [11 section 12.5]
- 1042 At least one class-like operand is required with Name --
- In defining (or declaring) an operator you must have at
- least one class as an operand. [11 section 13.4]
- 1043 Attempting to 'delete' a non-pointer -- An expression
- being delete'd is a non-pointer, non-array. You may only
- delete that created with an invocation of new.
- [11 section 5.3.4]
- 1046 member 'Symbol', referenced in a static function, requires
- an object -- The Symbol is a non-static member of a class
- and hence requires a class instantiation. None is in
- sight. [10 section 9.4]
- 1047 a template declaration must be made at file scope -- A
- template declaration may not appear within a function or
- within a class. [10 section 14.1]
- 1048 expected a constant expression -- Within a template
- argument list a constant expression was expected. An
- expression of the form T<arg1,arg2,...> was encountered
- and arg i for some i corresponds to a non-class parameter
- in the original template declaration. Such arguments need
- to be constants. [10 section 14.5]
- 1049 Too many template arguments -- There are more arguments
- in the template class-name than there were parameters in
- the original template declaration. [10 section 14.5]
- 1050 expected a template argument list '<...>' for template
- 'Symbol' -- The name of a class template identified by
- Symbol was used without specifying a template argument
- list. [10 section 14.5]
- 1051 Symbol 'Name' is both a function and a variable --
- Whereas it is possible to overload a function name by
- giving it two different parameter lists, it is not
- possible to overload a name in any other way. In
- particular a function name may not also be used as a
- variable name. [11 section 9.2]
- 1052 a type was expected, 'class' assumed -- A template
- parameter list consists of 2 kinds of parameters: class
- identifier and type. The parameter did not begin with
- class and was not a type. [10 section 14.5]
- 1053 'String' cannot be distinguished from 'String' -- An
- overloaded function name had two parameter lists that were
- so close that discrimination between them would be
- difficult and error prone. Eg. void f(const int); and
- void f(int); [11 section 13]
- 1054 template variable declaration expects a type, int assumed
- -- An expression of the form T<arg,arg,...> was
- encountered. One of the arguments corresponding to a type
- parameter in the original template declaration is not a
- type. [10 section 14.5]
- 1055 Symbol 'Symbol' undeclared, assumed to return int --
- Whereas in C you may call a function without a prior
- declaration, in C++ you must supply such a declaration.
- For C programs you would have received an Informational
- message ( 718) in this event. [11 section 5.2.2]
- 1056 assignment from void * is not allowed in C++ -- Whereas
- in C you may assign from void* to any other (data) pointer
- without a diagnostic, in C++ you may not do this. It will
- require a cast. [11 section 4.6]
- 1057 member 'Symbol' cannot be used without an object -- The
- indicated member referenced via scope operator cannot be
- used in the absence of this pointer. [11 section 5.2.4]
- 1058 Initializing a non-const reference 'Symbol' with a
- non-lvalue -- A reference is normally initialized with an
- lvalue. If you attempt to initialize a reference with a
- non-lvalue, a temporary is created to serve as a surrogate
- lvalue. However, modifications made to the temporary will
- be lost. This was legal at one time and is now illegal.
- Make the reference a const if you can. You may be
- initializing a reference without realizing it. A member
- function has an implicit parameter, which is taken to be a
- reference to its object. If this is the situation make
- the member const. That is, use void f(...) const; rather
- than void f(...);
- 1059 Can't convert from Type to Type -- An attempt was made to
- initialize a reference with an object having a type other
- than the target type but no function could be found to
- effect the required conversion. [11 section 12.3]
- 1060 String member 'Symbol is not accessible to non-member
- non-friend functions -- There is an attempt to access a
- private or protected member of a class and the access is
- considered a violation of the access rules (although
- everything else proceeds as though no violation occurred).
- Specifically, the function attempting to make access must
- be a friend or member of the nominal class through which
- the access is made. See also 1061. [11 section 11]
- 1061 String member 'Symbol' is not accessible through
- non-public inheritance -- There is an attempt to access a
- private, protected or public member (the text of the
- message indicates which kind as well as which member) of a
- class through a class derived from the original. There is
- an access violation (see 1060 for the more common access
- violation) critically dependent on the fact that the
- inheritance relationship is non-public. [11 section
- 11.2]
- 1062 template must be either a class or a function --
- Following template < arglist > the parser expects to find
- either the token class or a function declaration or
- definition. [10 section 14.5]
- 1063 Argument to copy constructor for class 'Symbol' should be
- a reference -- A constructor for a class closely
- resembles a copy constructor. A copy constructor for
- class X is typically declared as:
- X( const X &)
- If you leave off the '&' then a copy constructor would be
- needed just to copy the argument into the copy
- constructor. This is a runaway recursion. [11 section 12.1]
- 1064 Template parameter list for template 'Symbol' inconsistent
- with Location -- The template parameter list for a
- template function declaration or definition is
- inconsistent with that of a prior declaration or
- definition. [10 section 14.5]
- 1065 Symbol 'Symbol' not declared as "C" conflicts with
- Location -- A symbol previously declared as extern "C" in
- some other module is not declared as extern "C" in this
- module. This could be the source of very mysterious
- linker diagnostics since a name declared as extern "C" is
- not subject to the name mangling procedures that strictly
- C++ functions are. [11 section 7.4]
- 1066 Symbol 'Symbol' declared as "C" conflicts with Location
- -- A symbol is being declared as extern "C" and was not so
- declared in some other module. This could be the source
- of very mysterious linker diagnostics since a name
- declared as extern "C" is not subject to the name mangling
- procedures that strictly C++ functions are. [11 section
- 7.4]
- 1067 invalid prototype for function 'Symbol' -- Whenever
- operator delete or operator delete [] is defined its first
- parameter must be declared as void *. For member
- functions an optional second parameter may be size_t.
- [10 section 12.5].
- 1068 Symbol 'Symbol' can not be overloaded -- operator delete
- or operator delete [] can be redefined but not overloaded.
- There can only be one operator delete and one operator
- delete [] but neither of these can be overloaded. [10
- section 12.5].
- 1069 Symbol 'Name' is not a base class of class 'Name' --
- Within a constructor initialization list a name was found
- that did not correspond to either a direct base class of
- the class being defined or a member of the class.
- 1070 No scope in which to find symbol 'Name' -- This could
- arise in an expression of the form X::Y where X does not
- represent a valid scope.
- 1071 Constructors and destructors can not have return type --
- Constructors and destructors may not be declared with a
- return type, not even void. See ARM Section 12.1 and 12.4.
- 1072 Reference variable 'Symbol' must be initialized -- A
- reference variable must have an initializer at the point
- of declaration.
- 1073 Insufficient number of template parameters; 'String'
- assumed -- A (class) template instantiation did not have
- a sufficient number of parameters. String indicates what
- the missing argument is presumed to be.
- 1074 Expected a namespace identifier -- In a declaration of
- the form:
- namespace name = scoped-identifier
- the scoped-identifier must identify a namespace.
- 1075 Ambiguous reference to symbol 'Symbol' and symbol 'Symbol'
- -- Two namespaces contain the same name. A reference to
- such a name could not be disambiguated. You must fully
- qualify this name in order to indicate the name intended.
- 1077 Could not evaluate default template parameter 'String' --
- The evaluation of template parameters is deferred until
- needed. Thus:
- template< class T = abc > class A { /* ... */ };
- will be greeted with an Error 1077 only if an
- instantiation of A requires evaluation of the default
- argument and if that evaluation cannot be made. In that
- event int is assumed for type parameters and 0 is assumed
- for object parameters.
- 1078 class 'Symbol' should not have itself as a base class --
- The following situation will trigger this message.
- class A : public A { };
- You can't define A in terms of itself as there is no
- escape from the recursive plummet.
- 1079 Could not find '>' or ',' to terminate template parameter
- at Location -- The default value for a template parameter
- appears to be malformed. For example, suppose the user
- mistakenly substituted a ']' for a '>' producing the
- following:
- template <class T = A< int ] >
- class X
- {
- };
- This will cause PC-lint/FlexeLint to process to the end of
- the file looking (in vain) for the terminating pointy
- bracket. Not finding it will cause this message to be
- printed. Fortunately, the message will bear the Location
- of the malformed template.
- 1080 Definition for class 'Name' is not in scope -- This
- message would be issued whenever a class definition were
- required and it were not available. For example:
- Class X; // declare class X
- X *p; // OK, no definition required
- X a; // Error 1080
- 17.8 C++ Warning Messages
- 1401 member symbol 'Symbol' (Location) not initialized by
- constructor -- The indicated member symbol was not
- initialized by a constructor. Was this an oversight?
- 1402 member 'Symbol' (Location) not initialized -- The
- indicated member symbol was not initialized before use.
- Either this is in a constructor where it is presumed that
- no members are pre-initialized or this is after a
- statement removing its initialization such as a delete or
- a free.
- 1403 member 'Symbol' (Location) not initialized -- The
- indicated member symbol was not initialized before a point
- where its address is being passed to a constant pointer.
- This looks suspicious. Either this is in a constructor
- where it is presumed that no members are pre-initialized
- or this is after a statement removing its initialization
- such as a delete or a free.
- 1404 deleting an object of type 'Symbol' before type is defined
- -- The following situation was detected:
- class X; ... X *p; ... delete p;
- That is, a placeholder declaration for a class is given
- and an object of that type is deleted before any
- definition is seen. This may or may not be followed by
- the actual class definition:
- class X { ... };
- A delete before the class is defined is dangerous because,
- among other things, any operator delete that may be
- defined within the class could be ignored.
- 1411 Member with different signature hides virtual member
- 'Symbol' (Location) -- A member function has the same
- name as a virtual member of a derived class but it has a
- different signature (different parameter list). This is
- legal but suspicious, because it looks as though the
- function would override the virtual function but doesn't.
- You should either adjust the parameters of the member so
- that the signatures conform or choose a different name.
- See also message 1511.
- 1412 Reference member 'Symbol' is not initialized -- A class
- member typed reference to class (or struct or union) is
- mentioned in a constructor initializer list. But the
- class (or struct or union) referenced has no constructor
- and so is never initialized.
- 1413 function 'Symbol' is returning a temporary via a reference
- -- It appears that a function (identified as Symbol in the
- message) declared to return a reference is returning a
- temporary. According to the C++ standard (Section 12.2),
- in addressing the issue of binding temporary values to
- references, says "A temporary bound to the returned value
- in a function return statement ... persists until the
- function exits". Thus the information being returned is
- not guaranteed to last longer than the function being called.
- It would probably be better to return by value rather than
- reference. Alternatively, you may return a static
- variable by reference. This will have validity at least
- until the next call upon the same function.
- 1501 data member 'Symbol' has zero size -- A data member had
- zero size. It could be an array of zero length or a class
- with no data members. This is considered an error in C
- (Error 43) but in C++ we give this warning. Check your
- code to make sure this is not an error. Some libraries
- employ clever templating, which will elicit this message.
- In such a case it is necessary for you to inhibit the
- message outright (using -e1501) or through a judicious use
- of -esym(1501,...).
- 1502 defined object 'Symbol' has no data members -- A variable
- (Symbol) is being instantiated that belongs to a class
- that contains no data members (either directly or
- indirectly through inheritance). [11 section 9]
- 1503 a tagged union is not anonymous -- A tagged union without
- a declarator appeared within a struct/union declaration.
- An anonymous union requires no tag. [11 section 9.5]
- 1504 useless struct declaration -- An untagged struct
- declaration appeared within a struct/union and has no
- declarator. It is not treated like an anonymous union.
- Was this intended?
- 1505 no access specifier provided, 'String' assumed -- A base
- class specifier provides no access specifier (public,
- private or protected). An explicit access specifier is
- always recommended since the default behavior is often not
- what is expected. For example:
- class A : B { int a; };
- would make B a private base class by default.
- class A : private B { int a; };
- is preferred if that's what you want. [11 section 11.1]
- 1506 Call to virtual function 'Symbol' within a constructor or
- destructor -- A call to a virtual function was found in a
- constructor or a destructor of a class. If this class is
- a base class of some other class (why else make a virtual
- call?), then the function called is not the overriding
- function of the derived class but rather the function
- associated with the base class. If you use an explicit
- scope operator this message will not be produced. [20
- section 9]
- 1507 attempting to 'delete' an array -- The type of an object
- to be delete'd is usually a pointer. This is because
- operator new always returns a pointer and delete may only
- delete that allocated via new. Perhaps this is a
- programmer error attempting to delete an auto array? [19]
- 1509 base class destructor for class 'Name' is not virtual --
- The indicated class is a base class for some derived
- class. It has a non-virtual destructor. Was this a
- mistake? It is conventional to virtualize destructors of
- base classes so that it is safe to delete a base class
- pointer. [19]
- 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 section 4]
- 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.
- 1512 destructor for base class 'Symbol' (Location) is not
- virtual -- In a final pass through all the classes, we
- have found a class (named in the message) that is the base
- class of a derivation and has a destructor but the
- destructor is not virtual. It is conventional for
- inherited classes to have virtual destructors so that it
- is safe to 'delete' a pointer to a base class. [19]
- 1513 storage class ignored -- A storage class (one of auto,
- extern, or register) was found within a class definition.
- The only storage classes that are significant when
- declaring members are static and typedef. [11 section 9.2]
- 1514 Creating temporary to copy 'Type' to 'Type' (context:
- Context) -- A temporary was created in order to
- initialize (or pass a value to or return a value to) a
- reference. This is suspect because any modification to
- the value will be a modification of this temporary. This
- message is not issued when initializing a const reference.
- [11 section 12.2]
- 1515 Default constructor not available for member 'Symbol' --
- A member of a class was found that had a type for which a
- constructor was defined but for which a default
- constructor (one with no arguments) was not defined.
- 1516 Data member hides inherited member 'Symbol' (Location) --
- A data member of a class happens to have the same name as
- a member of a base class. Was this deliberate? Identical
- names can cause confusion. To inhibit this message for a
- particular symbol or for an identifiable set of symbols
- use -esym().
- 1520 Multiple assignment operators for class 'Symbol' -- More
- than one assignment operator has been declared for a given
- class. For example, for class X there may have been
- declared:
- void operator=(X);
- void operator=(X) const;
- Which is to be used for assignment?
- 1521 Multiple copy constructors for class 'Symbol' -- For a
- given class, more than one function was declared that
- could serve as a copy constructor. Typically this means
- that you declared both X( X& ) and X( const X& ) for the
- same class. This is probably a mistake.
- 1522 Symbol 'Symbol' is an array of empty objects -- An array
- (Symbol) is being allocated. Each member of the array
- appears to be empty. Although this is legal, it could be
- the result of human error. If this is deliberate policy,
- inhibit the message, either globally, or for this Symbol.
- 1524 new in constructor for class 'Name' which has no explicit
- destructor -- A call to new has been found in a
- constructor for a class for which no explicit destructor
- has been declared. A destructor was expected because how
- else can the storage be freed? [10 section 12.5]
- 1526 Member function 'Symbol' (Location) not defined -- A
- member function (named in the message) of a non-library
- class was not defined. This message is suppressed for
- unit checkout (-u option).
- 1527 static member 'Symbol' (Location) not defined -- A static
- data member (named in the message) of a non-library class
- was not defined. In addition to its declaration within
- the class, it must be defined in some module.
- 1528 call to String does not match function template String --
- The first String of the message designates an actual
- function call that appeared to be the invocation of the
- template function identified by the second String. No
- match could be made between the arguments of the call and
- the template parameters.
- 1529 Symbol 'Symbol' not first checking for assignment to this
- -- The assignment operator does not appear to be checking
- for assignment of the value of a variable to itself
- (assignment to this). Specifically PC-lint/FlexeLint is
- looking for one of:
- if( &arg == this )
- if( &arg != this )
- if( this == &arg )
- if( this != &arg )
- as the first statement of the function.
- It is important to check for a self assignment so as to
- know whether the old value should be subject to a delete
- operation. This is often overlooked by a class designer
- since it is counter-intuitive to assign to oneself. But
- through the magic of aliasing (pointers, references,
- function arguments) it is possible for an unsuspecting
- programmer to stumble into a disguised self-assignment
- [12, Item 17].
- If you are currently using the following test
- if( arg == *this)
- we recommend you replace this with the more efficient:
- if( &arg == this || arg == *this)
- 1531 Symbol 'Symbol' (Location) should have compared argument
- against sizeof(class) -- This warning is given for either
- operator new or operator delete when defined as member
- functions of a class that is the base class of a
- derivation. In this case you can't be certain of the size
- of allocation and therefore your allocation functions
- should test the size parameter for equality to the sizeof
- the class. See Elective Note 1921 for more details.
- 1532 Symbol 'Symbol' not checking argument for NULL -- This
- message is given for a function operator delete which is a
- member function of a class that does not have a
- destructor. It should check for NULL because delete p
- where p has the NULL value will be passed in to it. See
- also 1922.
- 1533 Repeated friend declaration for symbol 'Symbol' -- A
- friend declaration for a particular symbol (class or
- function) was repeated in the same class. Usually this is
- a harmless redundancy.
- 1534 static variable 'Symbol' found within inline function in
- header -- A static variable (Symbol) was found within an
- inline function within a header file. This can be a
- source of error since the static variable will not retain
- the same value across multiple modules. Rather each
- module will retain its own version of the variable. If
- multiple modules need to use the function then have the
- function refer to an external variable rather than a
- static variable. Conversely if only one module needs to
- use the function then place the definition of the function
- within the module that requires it. [23, Item 26].
- 1535 Exposing low access data through member 'Symbol' -- A
- member function is returning an address being held by the
- indicated member symbol (presumably a pointer). The
- member's access (such as private or protected) is lower
- than the access of the function returning the address.
- 1536 Exposing low access member 'Symbol' -- A member function
- is returning the non-const address of a member either
- directly or via a reference. Moreover, the member's
- access (such as private or protected) is lower than the
- access of the function returning the address. For
- example:
- class X
- {
- private:
- int a;
- public:
- int *f() { return &a; }
- };
- This looks like a breach of the access system [12, Item
- 30]. You may lower the access rights of the function,
- raise the accessibility of the member or make the return
- value a const pointer or reference. In the above example
- you could change the function to:
- const int *f() { return &a; }
- 1537 const function returns pointer data member 'Symbol' -- A
- const function is behaving suspiciously. It is returning
- a pointer data member (or equivalently a pointer to data
- that is pointed to by a data member). For example,
- class X
- {
- int *p;
- int *f() const { return p; }
- };
- Since f is supposedly const and since p is presumptively
- pointing to data that is logically part of class X we
- certainly have the potential for a security breach.
- Either return a pointer to const or remove the const
- modifier to the function. [12, Item 29 ].
- Note, if a const function returns the address of a data
- member then a 605 (capability increase) is issued.
- 1538 base class 'Name' absent from initializer list for copy
- constructor -- The indicated base class did not appear in
- the initializer list for a copy constructor. Was this an
- oversight? If the initializer list does not contain an
- initializer for a base class, the default constructor is
- used for the base class. This is not normally appropriate
- for a copy constructor. The following is more typical:
- class B { ... };
- class D : public B
- {
- D( const D &arg ) : B( arg ) { ... }
- ...
- };
- 1539 member 'Symbol' (Location) not assigned by assignment
- operator -- The indicated Symbol was not assigned by an
- assignment operator. Was this an oversight? It is not
- strictly necessary to initialize all members in an
- assignment operator because the 'this' class is presumably
- already initialized. But it is easy to overlook the
- assignment of individual members. It is also easy to
- overlook your responsibility to assign base class members.
- This is not done for you automatically. [12, Item 16]
- The message is not given for const members or reference
- members. If you have a member that is deliberately not
- initialized you may suppress the message for that member
- only using -esym.
- 1540 pointer member 'Symbol' (Location) neither freed nor
- zero'ed by destructor -- The indicated member is a
- non-static pointer member of a class that was apparently
- not freed by the class' destructor. Was this an
- oversight? By freeing, we mean either a call to the
- free() function or use of the delete operator. If the
- pointer is only intended to point to static information
- during its lifetime then, of course, it never should be
- freed. In that case you should signal closure by assign
- ing it the NULL pointer (0).
- 1541 member 'Symbol' (Location) possibly not initialized by
- constructor -- The indicated member symbol may not have
- been initialized by a constructor. Was this an oversight?
- Some of the paths that the constructor takes do initialize
- the member. See Section 9.
- 1542 member 'Symbol' (Location) possibly not initialized --
- The indicated member symbol may not have been initialized
- before use. Either this is in a constructor where it is
- presumed that no members are pre-initialized or this is
- after a statement removing its initialization such as a
- delete or a free. See Section 9.
- 1543 member 'Symbol' (Location) possibly not initialized --
- The indicated member symbol may not have been initialized
- before a point where its address is being passed to a
- constant pointer. This looks suspicious. Either this is
- in a constructor where it is presumed that no members are
- pre-initialized or this is after a statement removing its
- initialization such as a delete or a free.
- 1544 value of variable 'Symbol' (Location) indeterminate (order
- of initialization) -- A variable (identified by Symbol)
- was used in the run-time initialization of a static
- variable. However this variable itself was initialized at
- run-time. Since the order of initialization cannot be
- predicted this is the source of possible error.
- Whereas addresses are completely known at initialization
- time values may not be. Whether the value or merely the
- address of a variable is used in the initialization of a
- second variable is not an easy thing to determine when an
- argument is passed by reference or via pointer. For example,
- class X
- {
- X( const X & );
- };
- extern X x1;
- X x2 = x1;
- X x1 = x2;
- It is theoretically possible, but unlikely, that the
- constructor X() is interested only in the address of its
- argument and not its current value. If so, it only means
- you will be getting a spurious report, which you can
- suppress based on variable name. However, if the const is
- missing when passing a reference parameter (or a pointer
- parameter) then we cannot easily assume that values are
- being used. In this case no report will be issued. The
- moral is that if you want to get the checking implied by
- this message you should make your constructor reference
- arguments const.
- 1545 value of variable 'Symbol' used previously to initialize
- variable 'Symbol' (Location) -- A variable identified by
- Symbol was used previously to initialize some other
- variable. This variable is now itself being initialized
- with run-time code. The order of these initializations
- cannot be predicted. See also message 1544.
- 1546 throw() called within destructor 'Symbol' -- The body of
- a destructor (signature provided within the message)
- contains a throw not within a try block. This is
- dangerous because destructors are themselves triggered by
- exceptions in sometimes unpredictable ways. The result
- can be a perpetual loop. [23, Item 11]
- 1547 Assignment of array to pointer to base class (Context) --
- An assignment from an array of a derived class to a
- pointer to a base class was detected. For example:
- class B { };
- class D : public B {};
- D a[10];
- B *p = a; // Warning 1547
- B *q = &a[0]; // OK
- In this example p is being assigned the address of the
- first element of an array. This is fraught with danger
- since access to any element other than the zeroeth must be
- considered an error (we presume that B and D actually have
- or have the potential to have different sizes). [23,
- Item 3].
- We do not warn about the assignment to q because it
- appears that the programmer realizes the situation and
- wishes to confine q to the base object of the zeroeth
- element of a only. As a further precaution against
- inappropriate array access, out of bounds warnings are
- issued for subsequent references to p[1] and q[1].
- 1548 Exception specification for 'Symbol' conflicts with
- Location -- The exception specification of a function
- begins with the keyword 'throw' and follows the prototype.
- Two declarations were found for the same function with
- inconsistent exception specifications.
- 1549 Exception thrown for function 'Symbol' not declared to
- throw -- An exception was thrown (i.e., a throw was
- detected) within a function and not within a try block;
- moreover the function was not declared to throw anything.
- The preferred remedy is to declare the function as
- potentially throwing an exception. [23, Item 11]
- 1550 function 'Symbol' may throw an exception in function
- 'Symbol' -- A function was called (first Symbol) which
- was declared to throw an exception. The call was not made
- from within a try block and the function making the call
- was not declared to throw anything. Either declare the
- calling function as potentially throwing an exception, or
- place the call inside a try block and catch the throw.
- 1551 function 'Symbol' may throw an exception in destructor
- 'Symbol' -- A call to a function (name given by the first
- Symbol) was made from within a destructor. The function
- was declared as potentially throwing an exception. Such
- exceptions need to be caught within a try block because
- destructors should never throw exceptions. [23, Item 11].
- 1552 Converting pointer to array-of-derived to pointer to base
- -- This warning is similar to Warning 1547 and is
- sometimes given in conjunction with it. It uses value
- tracking to determine that an array (that could be
- dynamically allocated) is being assigned to a base class
- pointer.
- For example,
- Derived *d = new Derived[10];
- Base *b;
- b = d; // Warning 1552
- b = &d[0]; // OK
- [23, Item 3] Also, see the article by Mark Nelson (Bug++
- of the Month, Windows developer's Journal, May 1997, pp. 43-44).
- 1553 struct 'Symbol' declared as extern "C" contains C++
- substructure 'Symbol' (Location) -- A C++ substructure
- was found in a structure or class declared as extern "C".
- Was this intended?
- 1554 Direct pointer copy of member 'Symbol' within copy
- constructor: 'Symbol' -- In a copy constructor a pointer
- was merely copied rather than recreated with new storage.
- This can create a situation where two objects have the
- same data and this, in turn, causes problems when these
- objects are deleted or modified. For example, the
- following class will draw this warning:
- class X
- {
- char *p;
- X( const X & x )
- { p = x.p; }
- ...
- };
- Here, member p is expected to be recreated using new or
- some variant.
- 1555 Direct pointer copy of member 'Symbol' within copy
- assignment operator: 'Symbol' -- In a copy assignment
- operator a pointer was merely copied rather than recreated
- with new storage. This can create a situation where two
- objects have the same data and this, in turn, causes
- problems when these objects are deleted or modified. For
- example, the following class will draw this warning:
- class X
- {
- char *p;
- X& operator=( const X & x )
- { p = x.p; }
- ...
- };
- Here, member p is expected to be recreated using new or
- some variant.
- 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.
- 1557 const member 'Symbol' is not initialized -- A class
- member typed const class (or struct or union) is mentioned
- in a constructor initializer list. But the class (or
- struct or union) referenced has no constructor and hence
- the member is not initialized. See also message 1769.
- 1559 Uncaught exception 'Name' may be thrown in destructor
- 'Symbol' -- The named exception occurred within a try
- block and was either not caught by any handler or was
- caught but then thrown from the handler. Destructors
- should normally not throw exceptions [23, Item 11].
- 1560 Uncaught exception 'Name' not on throw-list of function
- 'Symbol' -- A direct or indirect throw of the named
- exception occurred within a try block and was either not
- caught by any handler or was rethrown by the handler.
- Uncaught exceptions should normally be declared in the
- function's exception specification.
- 1561 Reference initialization causes loss of const/volatile
- integrity (Context) -- A reference initialization is
- resulting in a capability gain that can cause a loss of
- const or volatile integrity.
- Typically the message is given on initializing a non-const
- reference with a const. For example:
- void f( int &x );
- const int n = 0;
- ...
- f(n);
- Here, function f() could assign a value to its argument
- and thereby modify n, which is declared to be const.
- The message can also be issued when a pointer is
- initialized. Consider the following example.
- void h( const int *&q );
- int *p;
- ...
- h(p);
- It might seem that passing a regular (i.e., non-const)
- pointer to a const int * could cause no harm. That would
- be correct if it were not for the reference. If function
- h() were to assign a pointer to const to its parameter q
- then upon return from the call, p could be used to modify
- const data.
- There are many subtle cases that can boggle the mind. See
- the commentary to Message 605.
- 17.9 C++ Informational Messages
- 1701 redundant access-specifier 'String' -- The given access
- specifier (one of 'public', 'private' or 'protected') has
- been repeated. [11 section 11.1]
- 1702 operator 'Name' is both an ordinary function 'String' and
- a member function 'String' -- In attempting to resolve
- the definition of an operator it was found that the same
- operator was declared as both a member function and a
- non-member function. Was this intended? Symmetric binary
- operators (such as '+', '-', '==', '>', etc.) are usually
- defined external to a class definition so that they can
- support non-objects on the left hand side.
- [11 section 13.4.2]
- 1703 Function 'String' arbitrarily selected. Refer to Error
- 'Integer' -- This informational message is given with
- error numbers 1023, 1024, 1025 and 1026. These are
- issued when an error is encountered during the overload
- resolution process, and is issued merely to indicate which
- function was arbitrarily selected. [11 section 13.2]
- 1704 Constructor 'Symbol' has private access specification --
- A private constructor is legal and has its uses but can
- also result in messages that are difficult to interpret.
- If you use private constructors as a programming technique
- then you may suppress this message with a -e1704. But
- it's probably better to suppress this on a constructor by
- constructor basis using -esym.
- 1705 static class member may be accessed by the scoping
- operator -- A static class member was accessed using a
- class object and -> or . notation. For example:
- s.member
- or
- p->member
- But an instance of the object is not necessary. It could
- just as easily have been referenced as:
- X::member
- where X is the class name. [10 section 9.4]
- 1706 Declaration with scope operator is unusual within a class
- -- Class members within a class are not normally declared
- with the scope operator. For example:
- class X { int X::n; ...
- will elicit this message. If the (redundant) class
- specification (X::) were replaced by some different class
- specification and the declaration was not friend an error
- ( 1040) would be issued. [11 section 9.2]
- 1707 static assumed for String -- operator new() and operator
- delete(), when declared as member functions, should be
- declared as static. They do not operate on an object
- instantiation (implied this pointer). [11 section 12.5]
- 1708 typedef 'Symbol not declared as "C" conflicts with
- Location -- A typedef symbol previously declared as
- extern "C" was not so declared at the current location.
- This is not considered as serious a situation as is
- indicated by message 1065, which is given for external
- function and variable names. If this is your programming
- style you may suppress this message.
- 1709 typedef 'Symbol' declared as "C" conflicts with Location
- -- A typedef symbol was previously not declared as extern
- "C" but is so declared at the current location. This is
- not considered as serious a situation as is indicated by
- message 1066, which is given for external function and
- variable names. If this is your programming style you may
- suppress this message.
- 1711 class 'Symbol' (Location) has a virtual function but is
- not inherited -- The given class has a virtual function
- but is not the base class of any derivation. Was this a
- mistake? There is no advantage to making member functions
- virtual unless their class is the base of a derivation
- tree. In fact, there is a disadvantage because there is a
- time and space penalty for virtual functions. This
- message is not given for library classes and is suppressed
- for unit checkout. [13 section 4]
- 1712 default constructor not defined for class 'Name' -- A
- class was defined with one or more constructors but none
- of these could be used as a (0 argument) default
- constructor. Is this an omission? The default constructor
- is used in declarations and for new when no explicit
- initialization is given. It is also used when the class
- is a base class and no mem-initializer is given. It is
- used for arrays as well. A default constructor should
- therefore be omitted only for good reason. If you have
- such a good reason for class X you can employ option
- -esym(1712,X). [19]
- 1713 Redundant parentheses ignored -- A vacuous initializer
- within a new-initializer for an object for which a
- constructor was not defined is a "syntactic convenience
- and has no special meaning". For example, new double is
- the same as new double(). [11 section 5.3.3]
- 1714 Member function 'Symbol' (Location) not referenced -- A
- member function was not referenced. This message is
- automatically suppressed for unit checkout (-u) and for
- members of a library class.
- 1715 static member 'Symbol' (Location) not referenced -- A
- static data member of a class was not referenced. This
- message is automatically suppressed for unit checkout (-u)
- and for members of a library class.
- 1716 Virtual member function 'Symbol' (Location) not referenced
- -- A virtual member function was apparently not
- referenced. Not only was the function itself not
- referenced but the function or functions that it overrides
- were not referenced either. The message is not given if
- the member function itself or any member function that it
- overrides is a library member function. This is because
- the original virtual function may be called implicitly by
- the library.
- This message is suppressed for unit checkout (-u).
- 1717 empty prototype for function declaration, assumed '(void)'
- -- An empty prototype, as in:
- void f();
- has a different meaning in C than in C++. In C it says
- nothing about the arguments of the function; in C++, it
- says there are no arguments. This message is not given
- for member function declarations or for function
- definitions. Rather, weaker Elective Notes ( 1917 and
- 1918) are given. This is because the chance of ambiguity
- does not exist in these cases. [11 section 8.2.5]
- 1718 expression within brackets ignored -- In the expression:
- delete [ expression ] p
- the expression is ignored. The expression is a vestige of
- an earlier time when this information provided a count of
- the number of items in the array being released. Note
- that empty square brackets are considered necessary for
- deleting an array. This is a complaint directed toward
- the expression within the brackets not the brackets
- themselves. [11 section 5.3.4]
- 1719 assignment operator for class 'Symbol' has non-reference
- parameter -- The typical assignment operator for a class
- is of the form:
- X& operator =(const X &)
- If the argument is not a reference then your program is
- subject to implicit function calls and less efficient
- operation. [11 section 13.4.3]
- 1720 assignment operator for class 'Symbol' has non-const
- parameter -- The typical assignment operator for a class
- is of the form:
- X& operator =(const X &)
- If the argument is not const then your program will not be
- diagnosed as completely as it might otherwise be. [11
- section 13.4.3]
- 1721 operator =() for class 'Symbol' is not assignment operator
- -- The assignment operator for a class has the form:
- X& operator =(const X &)
- A member function whose name is operator =, but does not
- have that form, is not an assignment operator. This could
- be a source of subtle confusion for a program reader. If
- this is not an error you may selectively suppress this
- message for the given class. [11 section 13.4.3]
- 1722 assignment operator for class 'Symbol' does not return a
- reference to class -- The typical assignment operator for
- a class X is of the form:
- X& operator =(const X &);
- The reason for returning a reference to class is to
- support multiple assignment as in:
- a = b = c
- [11 section 13.4.3]
- 1724 Argument to copy constructor for class 'Symbol' should be
- a const reference -- A copy constructor for class X is
- typically declared as:
- X( const X & );
- If you leave off the 'const' then some diagnostics will
- not be possible. [19]
- 1725 class member 'Symbol' is a reference -- There are a
- number of subtle difficulties with reference data members.
- If a class containing a reference is assigned, the default
- assignment operator will presumably copy the raw
- underlying pointer. This violates the principle that a
- reference's underlying pointer, once established, is never
- modified. Some compilers protect against this eventuality
- by refusing to create a default assignment operator for
- classes containing references. Similar remarks can be
- made about copy constructors. If you are careful about
- how you design your copy constructors and assignment
- operators, then references within classes can be a useful
- programming technique. They should not, however, be
- employed casually. [21 section 2.1.3]
- 1726 taking address of overloaded function name 'Symbol' -- A
- reference is being made to an overloaded function without
- an immediately following '('. Thus there is no argument
- list to distinguish the function intended. Resolution of
- the overloaded name can only be made by analyzing the
- destination. Is this what the programmer intended? [11
- section 13.3]
- 1727 inline 'Symbol' not previously defined inline at
- (Location) -- A function declared or defined inline was
- not previously declared inline. Was this intended? If
- this is your standard practice then suppress this message.
- [11 section 9.3.2]
- 1728 Symbol 'Symbol' was previously defined inline at
- (Location) -- A function was previously declared or
- defined inline. The inline modifier is absent from the
- current declaration or definition. Was this intended? If
- this is your standard practice then suppress this message.
- [11 section 9.3.2]
- 1729 Initializer inversion detected for member 'Symbol' -- In
- a constructor initializer the order of evaluation is
- determined by the member order not the order in which the
- initializers are given. At least one of the initializers
- was given out of order. Was there a reason for this? Did
- the programmer think that by changing the order that
- he/she would affect the order of evaluation? Place the
- initializers in the order of their occurrence within the
- class so that there can be no mistaken assumptions.
- [12, Item 13]
- 1730 class/struct inconsistency for symbol 'Symbol' (conflicts
- with Location) -- An object is declared both with the
- keyword class and with the keyword struct. Though this is
- legal it is suspect. [11 section 7.1.6]
- 1732 new in constructor for class 'Name' which has no
- assignment operator -- Within a constructor for the cited
- class, there appeared a new. However, no assignment
- operator was declared for this class. Presumably some
- class member (or members) points to dynamically allocated
- memory. Such memory is not treated properly by the
- default assignment operator. Normally a custom assignment
- operator would be needed. Thus, if x and y are both of
- type Symbol
- x = y;
- will result in pointer duplication. A later delete would
- create chaos. [12, Item 11]
- 1733 new in constructor for class 'Name' which has no copy
- constructor -- Within a constructor for the cited class,
- there appeared a new. However, no copy constructor was
- declared for this class. Presumably, because of the new,
- some class member (or members) points to dynamically allo
- cated memory. Such memory is not treated properly by the
- default copy constructor. Normally a custom copy
- constructor would be needed. [12, Item 11]
- 1734 Had difficulty compiling template function: 'Symbol' --
- At template wrap-up time where there is an attempt to
- 'compile' each template function according to arguments
- provided, the cited function could not be processed fully.
- The difficulty may be the result of syntax errors cited
- earlier and if these errors are repaired then this message
- should go away.
- 1735 Virtual function 'Symbol' has default parameter -- A
- virtual function was detected with a default parameter.
- For example:
- class B
- {
- virtual void f( int n = 5 );
- ...
- };
- The difficulty is that every virtual function f overriding
- this virtual function must contain a default parameter and
- its default parameter must be identical to that shown
- above. If this is not done, no warnings are issued but
- behavior may have surprising effects. This is because
- when f() is called through a base class pointer (or
- reference) the function is determined from the actual type
- (the dynamic type) and the default argument is determined
- from the nominal type (the static type). [12, Item 38].
- 1736 Redundant access specifier (String) -- An access
- specifier (one of public, private, or protected as shown
- in String) is redundant. That is, the explicitly given
- access specifier did not have to be given because an
- earlier access specifier of the same type is currently
- active. This message is NOT given for an access specifier
- that is the first item to appear in a class definition.
- Thus
- class abc { private: ...
- does not draw this message. The reason this message is
- issued is because it is very easy to make the following
- mistake.
- class A
- {
- public: // declare private members:
- ...
- public: // declare public members:
- ...
- In general there are no compiler warnings that would
- result from such an unintentional botch.
- 1737 Symbol 'Symbol' hides global operator new -- The
- indicated Symbol is a class member operator new. It is
- not compatible with the global operator new and, moreover,
- no other operator new within the class is argument list
- compatible with the global operator new. For this reason
- the user of these classes will get a surprise if he/she
- calls for new X where X is the class name. It will be
- greeted with an error. The solution is to define a single
- argument operator new as a class member. [12, Item 9].
- 1738 non-copy constructor 'Symbol' used to initialize copy
- constructor -- In an initializer list for a copy
- constructor, a base class constructor was invoked.
- However, this base class constructor was not itself a copy
- constructor. We expect that copy constructors will invoke
- copy constructors. Was this an oversight or was there
- some good reason for choosing a different kind of con
- structor? If this was deliberate, suppress this message.
- See also message 1538.
- 1739 Binary operator 'Symbol' should be non-member function --
- The indicated function was declared as a member function.
- There were a number of indicators to suggest that it
- should have been a non-member function. The class, X of
- which it was a member has a constructor that could be used
- to convert numeric values to X. The parameter to the
- operator was X or its equivalent. For this reason the
- operator would behave unsymmetrically. A numeric value on
- the right hand side would be promoted but not a value on
- the left hand side. For example, X op 27 would work but
- 27 op X would not. [12, Item 19].
- 1740 pointer member 'Symbol' (Location) not directly freed or
- zero'ed by destructor -- A destructor did not free or
- zero a pointer member. However, it did call out to
- another (non-const) member function which may have done
- the required work. This Informational message is a
- companion to Warning 1540, which covers the situation
- where no member function is called from within the
- destructor.
- 1741 member 'Symbol' (Location) conceivably not initialized by
- constructor -- The indicated member symbol may not have
- been initialized by a constructor. Was this an oversight?
- There appears to be a path through a loop that does
- initialize the member and the warning is issued because it
- is not clear that the loop is always executed at least
- once. See Section 9.
- 1742 member 'Symbol' (Location) conceivably not initialized --
- The indicated member symbol conceivably may not have been
- initialized by a constructor. Was this an oversight?
- Some of the execution paths that the constructor takes, do
- initialize the member. See Section 9.
- 1743 member 'Symbol' (Location) conceivably not initialized --
- The indicated member symbol conceivably may not have been
- initialized before use. Either this is in a constructor
- where it is presumed that no members are pre-initialized
- or this is after a statement removing its initialization
- such as a delete or a free. See Section 9.
- 1744 member 'Symbol' (Location) possibly not initialized by
- private constructor -- The designated member was possibly
- not initialized by a private constructor. This message is
- similar to messages 1401, 1541 and 1741, which are
- given for ordinary (non private) constructors. It is
- given a special error number because a private constructor
- may be one that, by design, is never called and variables
- may be deliberately left uninitialized. In that case this
- message should be suppressed.
- 1745 member 'Symbol' (Location) not assigned by private
- assignment operator -- The indicated Symbol was not
- assigned by a private assignment operator. This is very
- much like Warning 1539 except that the assignment
- operator in question is private. A private assignment
- operator may simply be a device to thwart unintended use
- of the assignment operator. In this case you may not care
- about unassigned members. If this is so, suppress this
- message.
- The message is not given for const members or reference
- members. [12, Item 16]
- 1746 parameter 'Symbol' of function 'Symbol' could be made
- const reference -- The indicated parameter is a candidate
- to be declared as a const reference. For example:
- void f( X x )
- {
- // x not modified.
- }
- Then the function definition can be replaced with:
- void f( const X &x )
- {
- // x not modified.
- }
- The result is more efficient since less information needs
- to be placed onto the stack and a constructor need not be
- called.
- The message is only given with class-like arguments
- (including struct's and union's) and only if the parameter
- is not subsequently modified or potentially modified by
- the function. The parameter is potentially modified if it
- is passed to a function whose corresponding parameter is a
- reference (not const) or if its address is passed to a
- non-const pointer. [12, Item 22].
- 1747 binary operator 'Symbol' returning a reference -- An
- operator-like function was found to be returning a
- reference. For example:
- X &operator+ ( X &, X & );
- This is almost always a bad idea. [12, Item 23]. You
- normally can't return a reference unless you allocate the
- object, but then who is going to delete it. The usual way
- this is declared is:
- X operator+ ( X &, X & );
- 1748 non-virtual base class 'Name' included twice in class
- 'Name' -- Through indirect means, a given class was
- included at least twice as a base class for another class.
- At least one of these is not virtual. Although legal,
- this may be an oversight. Such base classes are usually
- marked virtual resulting in one rather than two separate
- instances of the base class. This is done for two rea
- sons. First, it saves memory; second, references to
- members of such a base class will not be ambiguous.
- 1749 base class 'Symbol' of class 'Symbol' need not be virtual
- -- The designated base class is a direct base class of the
- second class and the derivation was specified as
- 'virtual'. But the base class was not doubly included
- (using this link) within any class in the entire project.
- Since a virtual link is less efficient than a normal link
- this may well be an unenlightened use of 'virtual'. [23,
- Item 24]. The message is inhibited if unit checkout (-u)
- is selected.
- 1750 local template 'Symbol' (Location) not referenced -- A
- 'local' template is one that is not defined in a header
- file. The template was not used in the module in which it
- was defined.
- 1752 catch parameter Integer 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].
- 1753 Overloading special operator 'Symbol' -- This message is
- issued whenever an attempt is made to declare one of these
- operators as having some user-defined meaning:
- operator ||
- operator &&
- operator ,
- The difficulty is that the working semantics of the
- overloaded operator is bound to be sufficiently different
- from the built-in operators, as to result in possible
- confusion on the part of the programmer. With the
- built-in versions of these operators, evaluation is
- strictly left-to-right. With the overloaded versions,
- this is not guaranteed. More critically, with the
- built-in versions of && and ||, evaluation of the 2nd
- argument is conditional upon the result of the first.
- This will never be true of the overloaded version. [23,
- Item 7].
- 1754 Expected symbol 'Symbol' to be declared for class 'Symbol'
- -- The first Symbol is of the form: operator op= where op
- is a binary operator. A binary operator op was declared
- for type X where X is identified by the second Symbol.
- For example, the appearance of:
- X operator+( const X &, const X & );
- somewhere in the program would suggest that a += version
- appear as a member function of class X. This is not only
- to fulfill reasonable expectations on the part of the
- programmer but also because operator+= is likely to be
- more efficient than operator+ and because operator+ can be
- written in terms of operator+=. [23, Item 22]
- The message is also given for member binary operators. In
- all cases the message is not given unless the return value
- matches the first argument (this is the implicit argument
- in the case of a member function).
- 1755 global template 'Symbol' (Location) not referenced -- A
- 'global' template is one defined in a header file. This
- message is given for templates defined in non-library
- header files. The template is not used in any of the
- modules comprising the program. The message is suppressed
- for unit checkout (-u).
- 1757 Discarded instance of post decrement/increment -- A
- postfix increment or postfix decrement operator was used
- in a context in which the result of the operation was
- discarded. For example:
- X a;
- ...
- a++;
- In such contexts it is just as correct to use prefix
- decrement/increment. For example this could be replaced
- with:
- X a;
- ...
- ++a;
- The prefix form is (or should be) more efficient than the
- postfix form because, in the case of user-defined types,
- it should return a reference rather than a value (see
- 1758 and 1759). This presumes that the side effects of
- the postfix form are equivalent to those of the prefix
- form. If this is not the case then either make them
- equivalent (the preferred choice) or turn this message
- off. [23, Item 6].
- 1758 Prefix increment/decrement operator 'Symbol' returns a
- non-reference -- To conform with most programming
- expectations, a prefix increment/decrement operator should
- return a reference. Returning a reference is both more
- flexible and more efficient [23, Item 6].
- The expected form is as shown below:
- class X
- {
- X & operator++(); // prefix operator
- X operator++( int ); // postfix operator
- ...
- };
- 1759 Postfix increment/decrement operator 'Symbol' returns a
- reference. -- To conform with most programming
- expectations, a postfix increment/decrement operator
- should return a value as opposed to a reference.
- [23, Item 6]. See example in message 1758.
- 1760 Redundant template 'Symbol' defined identically at
- Location -- A template was defined identically in the
- same module. Was this a mistake?
- 1761 Declaration of function 'Symbol' hides overloaded function
- 'Symbol' (Location) -- A function declaration hides an
- overloaded function. This does not contribute to the
- overloaded-ness of the function but completely hides all
- the overloaded functions in some prior scope. If this is
- your intent suppress this message.
- 1762 Member function 'Symbol' could be made const -- The
- indicated (non-static) member function did not modify
- member data and did not call non-const functions.
- Moreover, it does not make any deep modification to the
- class member. A modification is considered deep if it
- modifies information indirectly through a class member
- pointer. Therefore it could and probably should be
- declared as a const member function. See also Info 1763
- and Elective Note 1962.
- 1763 Member function 'Symbol' marked as const indirectly
- modifies class -- The designated symbol is a member
- function declared as const. Though technically valid, the
- const may be misleading because the member function
- modifies (or exposes) information indirectly referenced by
- the object. For example:
- class X
- {
- char *pc;
- char & get(int i) const { return pc[i]; }
- };
- results in Info 1763 for function X::get. This is because
- the function exposes information indirectly held by the
- class X.
- Experts [24] recommend that a pair of functions be made
- available in this situation:
- class X
- {
- char *pc;
- const char & get(int i) const { return pc[i]; }
- char & get(int i) { return pc[i]; }
- };
- In this way, if the object is const then only the const
- function will be called, which will return the protected
- reference. Related messages are also 1762 and 1962.
- See also [12, Item 29] for a further description.
- 1764 Reference parameter could be declared const reference --
- As an example:
- int f( int & k ) { return k; }
- can be redeclared as:
- int f( const int & k ) { return k; }
- Declaring a parameter a reference to const offers
- advantages that a mere reference does not. In particular,
- you can pass constants, temporaries and const types into
- such a parameter where otherwise you may not. In addition
- it can offer better documentation.
- Other situations in which a const can be added to a
- declaration are covered in messages 818, 952, 953 and 954.
- 1768 Virtual function 'Symbol' has an access (String) different
- from the access (String) in the base class (String) -- An
- overriding virtual function has an access (public,
- protected or private) in the derived class different from
- the access of the overridden virtual function in the base
- class. Was this an oversight? Since calls to the
- overriding virtual function are usually made through the
- base class, making the access different is unusual (though
- legal).
- 1769 Member or base class 'Symbol' has no constructor -- An
- initializer of the form Symbol() is ignored. Symbol is
- either a class member with a class, struct, or union type
- or is a base class. In either case the class (or struct
- or union) has no constructor and hence what appears to be
- an initialization is not. See also message 1557.
- 1770 function 'Symbol' defined without function 'String' -- A
- typical Info 1770 message is:
- function 'operator new(unsigned)' defined without function
- 'operator delete'
- There are three others:
- operator delete without an operator new,
- operator new[] without an operator delete[], and
- operator delete[] without an operator new[].
- In general it is not a good idea to create one of these
- functions without the other in the pairing. [23, Item 27]
- You can suppress any of these without suppressing them
- all. Simply do a -esym(1770,name) where name is the first
- function named in the message.
- 1771 function 'Symbol' replaces global function -- This
- message is given for operator new and operator delete (and
- for their [] cousins) when a definition for one of these
- functions is found. Redefining the built-in version of
- these functions is not considered sound programming
- practice. [23, Item 27]
- 1772 Assignment operator 'Symbol' is not returning *this --
- The assignment operator should return *this. This is to
- allow for multiple assignments as in:
- a = b = c;
- It is also better to return the object that has just been
- modified rather than the argument. [12, Item 15]
- 1773 Attempt to cast away const (or volatile) -- An attempt
- was made to cast away const. This can break the integrity
- of the const system. This message will be suppressed if
- you use const_cast. Thus:
- char *f( const char * p )
- {
- if( test() )
- return (char *) p; // Info 1773
- else
- return const_cast<char *>(p); // OK
- }
- See [12, Item 21].
- 1774 Could use dynamic_cast to downcast ptr to polymorphic type
- 'Symbol' -- A downcast was detected of a pointer to a
- polymorphic type (i.e., one with virtual functions). A
- dynamic_cast could be used to cast this pointer safely.
- For example:
- class B { virtual ~B(); };
- class D : public B {};
- ...
- D *f( B *p )
- {
- return dynamic_cast<D*>(p);
- }
- In the above example, if p is not a pointer to a D then
- the dynamic cast will result in a NULL pointer value. In
- this way, the validity of the conversion can be directly
- tested.
- B needs to be a polymorphic type in order to use
- dynamic_cast. If B is not polymorphic, message 1939 is
- issued.
- 1775 catch block does not catch any declared exception -- A
- catch handler does not seem to catch any exceptions. For
- example:
- try { f(); }
- catch( B& ) {}
- catch( D& ) {} // Info 1775
- catch( ... ) {}
- catch( char * ) {} // Info 1775
- If f() is declared to throw type D, and if B is a public
- base class of D, then the first catch handler will process
- that exception and the second handler will never be used.
- The fourth handler will also not be used since the third
- handler will catch all exceptions not caught by the first
- two.
- If f() is not declared to throw an exception then Info
- 1775 will be issued for all four catch handlers.
- 1776 Converting string literals to char * is deprecated
- (Context) -- A string literal, according to Standard C++
- is typed an array of const char. This message is issued
- when such a literal is assigned to a non-const pointer.
- For example:
- char *p = "string";
- will trigger this message. This pointer could then be
- used to modify the string literal and that could produce
- some very strange behavior.
- Such an assignment is legal but "deprecated" by the C++
- Standard. The reason for not ruling it illegal is that
- numerous existing functions have their arguments typed as
- char * and this would break working code.
- Note that this message is only given for string literals.
- If an expression is typed as pointer to const char in some
- way other than via string literal, then an assignment of
- that pointer to a non-const pointer will receive a more
- severe warning.
- 17.10 C++ Elective Notes
- 1901 Creating a temporary of type 'Symbol' --
- PC-lint/FlexeLint judges that a temporary needs to be
- created. This occurs, typically, when a conversion is
- required to a user object (i.e. class object). Where
- temporaries are created, can be an issue of some concern
- to programmers seeking a better understanding of how their
- programs are likely to behave. But compilers differ in
- this regard.
- 1902 useless ';' follows '}' in function definition -- It is
- possible to follow a function body with a useless
- semi-colon. This is not necessarily 'lint' to be removed
- but may be a preferred style of programming (as
- semi-colons are placed at the end of other declarations).
- 1904 Old-style C comment -- For the real bridge-burner one can
- hunt down and remove all instances of the /* ... */ form
- of comment. [12, Item 4]
- 1905 implicit default constructor generated for class 'Name'
- -- A default constructor was not defined for a class but a
- base class or a member has a non-trivial default
- constructor and so a non-trivial default constructor is
- generated for this class.
- 1907 implicit destructor generated for class 'Name' -- The
- named class does not itself have an explicit destructor
- but either had a base class that has a destructor or has a
- member class that has a destructor (or both). In this
- case a destructor will be generated by the compiler. [11
- section 12.4]
- 1908 'virtual' assumed for destructor'~Name()' (inherited from
- base class 'Name() -- The destructor cited was inherited
- from a base class with a virtual destructor. This word
- 'virtual' was omitted from the declaration. It is common
- practice to omit this keyword when implied. A warning is
- issued ( 1512) when a base class's destructor is not
- virtual. See also 1909.
- 1909 'virtual' assumed, see: function 'Symbol' (Location) --
- The named function overrides a base class virtual function
- and so is virtual. It is common practice to omit the
- virtual keyword in these cases although some feel that
- this leads to sloppy programming. This message allows pro
- grammers to detect and make explicit which functions are
- actually virtual.
- 1911 Implicit call of constructor 'Symbol' (see text) -- The
- Symbol in the message is the name of a constructor called
- to make an implicit conversion. This message can be
- helpful in tracking down hidden sources of inefficiencies.
- [11 section 12.1]
- 1912 Implicit call of conversion function from class 'Name' to
- type 'Type' -- A conversion function (one of the form
- Symbol::operator Type ()) was implicitly called. This
- message can be helpful in tracking down hidden sources of
- inefficiencies.
- 1914 Default constructor 'Symbol' (Location) not referenced --
- A default constructor was not referenced. When a member
- function of a class is not referenced, you will normally
- receive an Informational message ( 1714) to that effect.
- When the member function is the default constructor,
- however, we give this Elective Note instead.
- The rationale for this different treatment lay in the fact
- that many authors recommend defining a default constructor
- as a general principle. Indeed we give an Informational
- message ( 1712) when a default constructor is not defined
- for a class. Therefore, if you are following a modus
- operandi of not always defining a default constructor you
- may want to turn off message 1712 and turn on message
- 1914 instead.
- 1916 Ellipsis encountered -- An ellipsis was encountered while
- processing the prototype of some function declaration. An
- ellipsis is a way of breaking the typing system of C or C++.
- 1917 empty prototype for definition, assumed '(void)' --
- Whereas we give an Informational Message ( 1717) when a
- (non-member) declaration contains no prototype, we give a
- much milder Elective Note when a definition does the same.
- For example:
- int f(); // Info 1717
- int f() { return 1; } // Elective Note 1917
- The reason for this is that the declaration form has a
- different meaning in C and C++. In C it is an incomplete
- declaration saying nothing about arguments. In C++ the
- declaration says there are no arguments. The definition,
- however, means the same in both languages. See also
- message 1918. [11 section 8.2.5]
- 1918 empty prototype for member declaration, assumed (void) --
- A function declaration within a class contains an empty
- prototype. This case is similar to Info 1717, which
- complains about an empty prototype outside a class. It
- receives a lighter classification (Elective Note) because
- an empty prototype within a class cannot be ambiguous
- because C does not allow functions within classes.
- [11 section 8.2.5]
- 1919 Multiple assignment operators for class 'Symbol' -- For a
- given class more than one function was declared whose name
- was 'operator ='. This is not necessarily a bad thing.
- For example, a String class may very well have an
- assignment from char * and such an assignment may be
- advisable from an efficiency standpoint. However, it
- represents a loss of elegance because there will almost
- certainly be a char * constructor and an assignment
- operator, which will represent another way of achieving
- the same effect.
- 1920 Casting to a reference -- The ARM [11] (Section 5.4)
- states that reference casts are often 'misguided'.
- However, too many programs are openly using reference
- casts to place such casts in the Informational category.
- [11 section 5.4]
- 1921 Symbol 'Symbol' not checking argument against
- sizeof(class) -- This note is given for either operator
- new or operator delete when defined as member functions.
- As member functions they are called when new (or delete)
- is applied to a class type or any derived class type. The
- difficulty is with the derived class type. Any
- specialized allocator is likely to be useless for a derived
- class type and hence experts suggest that a test
- be made of the size_t argument against sizeof(class).
- Specifically PC-lint/FlexeLint is looking for one of:
- if( arg == sizeof(class) )
- if( arg != sizeof(class) )
- if( sizeof(class) == arg )
- if( sizeof(class) != arg )
- or the equivalent. If any such function is found that is
- a member of a class that is the base of a derivation, then
- in addition to Note 1921, we issue Warning 1531. (see
- Steve Simpson, "More on Memory Management", Dr. Dobb's
- Journal, August 1994, p. 10).
- 1922 Symbol 'Symbol' not checking argument for NULL -- This
- message is given for a function operator delete which is
- not checking its parameter for being the NULL pointer. We
- would normally expect to see some such check as:
- if( arg )
- if( arg == 0 )
- if( arg != NULL )
- etc. Class destructors will normally filter out passing
- the NULL pointer into the operator delete so that this
- message is only in the Elective Note category. If there
- is no destructor you obtain a warning. See Warning 1532.
- 1923 macro 'Symbol' could become const variable -- The
- designated macro could probably be replaced by a const
- variable. A const variable is preferred in some quarters
- where, for example, a local debugger may not understand
- macros but would understand variables. [12, Item 1].
- The message is issued for macros containing at least one
- constant or constant equivalent (an earlier const-able
- macro or const variable) and no other variables or tokens
- such as ';' of a non-expression nature.
- 1924 C-style cast -- A C-style cast was detected. This can be
- replaced by one of the newer C++ casts having the form:
- Name<Type>(Expression) where Name is one of static_cast,
- dynamic_cast, const_cast or reinterpret_cast. [23, Item 2].
- 1925 Symbol 'Symbol' is a public data member -- The indicated
- Symbol is a public data member of a class. If the class
- is introduced with the keyword struct the message is not
- issued. In some quarters the use of public data members
- is deprecated. The rationale is that if function calls
- replace data references in the public interface, the
- implementation can change without affecting the interface.
- [12, Item 20]
- 1926 Symbol 'Symbol's default constructor implicitly called --
- A member of a class (identified by Symbol) did not appear
- in the constructor initialization list. Since it had a
- default constructor this constructor was implicitly
- called. Is this what the user intended? Some authorities
- suggest that all members should appear in the constructor
- initialization list. [12, Item 12].
- 1927 Symbol 'Symbol' was not initialized in the constructor
- initializer list -- A member of a class (identified by
- Symbol) did not appear in a constructor initialization
- list. If the item remains uninitialized through the whole
- of the constructor, a Warning 1401 is issued. Some
- authorities suggest that all members should appear in the
- constructor initialization list. [12, Item 12].
- 1928 Symbol 'Name' did not appear in the constructor
- initializer list -- A base class (identified by Symbol)
- did not appear in a constructor initialization list. If a
- constructor does not appear, then the default constructor
- is called. This may or may not be valid behavior. If a
- base class is missing from a copy constructor's
- initializer list, then a more severe Warning ( 1538) is
- issued. [12, Item 12].
- 1929 function 'Symbol' returning a reference -- A non-member
- function was found to be returning a reference. This is
- not normally considered good practice because
- responsibility for deleting the object is not easily
- assigned. [12, Item 23].
- 1930 Conversion operator 'Symbol' found -- A conversion
- operator is a member function of the form:
- operator Type ();
- This will be called implicitly by the compiler whenever an
- object (of the class type) is to be converted to type
- Type. Some programmers consider such implicit calls to be
- potentially harmful leading to programming situations that
- are difficult to diagnose. See for example [23, Item 5].
- 1931 Constructor 'Symbol' can be used for implicit conversions
- -- A constructor was found that could be used for implicit
- conversions. For example:
- class X
- {
- public:
- X(int);
- ...
- };
- Here, any int (or type convertible to int) could be
- automatically converted to X. This can sometimes cause
- confusing behavior [23, Item 5]. If this is not what was
- intended, use the keyword 'explicit' as in:
- explicit X(int);
- This will also serve to suppress this message.
- 1932 Base class 'Symbol' is not abstract. -- An abstract class
- is a class with at least one pure virtual specifier. At
- least one author has argued [23, Item 33] that all base
- classes should be abstract although this suggestion flies
- in the face of existing practice.
- 1933 Call to unqualified virtual function 'Symbol' from
- non-static member function -- A classical C++ gotcha is
- the calling of a virtual function from within a
- constructor or a destructor. When we discover a direct call
- from a constructor or destructor to a virtual
- function we issue Warning 1506. But what about indirect
- calls. Suppose a constructor calls a function that in
- turn, perhaps through several levels of call, calls a
- virtual function. This could be difficult to detect. Dan
- Saks [24] has suggested a compromise Guideline that
- "imposes few, if any, practical restrictions". The
- Guideline, implemented by this Elective Note, issues a
- message whenever an unqualified virtual function is called
- by any other (non-static) member function (for the same
- 'this' object). For example:
- class X { virtual void f(); void g(); };
- void X::g()
- {
- f(); // Note 1933
- X::f(); // ok -- non virtual call.
- }
- Even if total abstinence is unwarranted, turning on
- message 1933 occasionally can be helpful in detecting
- situations when constructors or destructors call virtual
- functions.
- 1934 Shift operator 'Symbol' should be non-member function --
- It has been suggested [12, Item 19] that you should never
- make a shift operator a member function unless you're
- defining ostream or istream (the message is suppressed in
- these two cases). The reason is that there is a
- temptation on the part of the novice to, for example,
- define output to ostream as a class member function left
- shift that takes ostream as an argument. This is exactly
- backwards. The shift operator normally employs the
- destination (or source) on the left.
- On the other hand, if the class you are defining is the
- source or destination then defining the shift operators is
- entirely appropriate.
- 1935 Dynamic initialization for class object 'Symbol1'
- (references 'Symbol2') -- A static class-like object
- whose name is Symbol1 is dynamically initialized by
- referencing Symbol2 (the latter is normally a constructor
- for the former). The reason for noting this
- initialization is that the order of inter-module dynamic
- initializations is not defined. (Within a module,
- however, the intializations are done in the order of
- appearance.) Hence, if the constructor is itself
- dependent on dynamic initialization occurring in another
- module the behavior is undefined. For example:
- class X
- { X(): ... };
- X x:
- This will elicit Elective Note 1935 that x is being
- initialized dynamically by a call to X::X(). Now, if this
- constructor were to be accessing information that depended
- on the order of evaluation (such as accessing the value of
- x itself) the result would be undefined. We have no
- evidence of this at this point. and for this reason the
- message is in the Elective Note category. However,
- programmers with a suspected order-of-initialization
- problem will probably want to turn this on. See also
- 1936, 1937, 1544 and 1545.
- 1936 Dynamic initialization for variable 'Symbol1' (references
- 'Symbol2') -- A static scalar whose name is Symbol1 is
- dynamically initialized and references Symbol2 during the
- initialization. For example, let a module consist only
- of:
- int f();
- int n = f();
- Here we report that n is dynamically initialized by f().
- There may be other symbols referenced, Symbol2 is just the
- first. The reason for noting this initialization is that
- the order of inter-module dynamic initializations is not
- defined. (Within a module, however, the initializations
- are done in the order of appearance.) If Symbol2 were a
- variable, then PC-lint/FlexeLint could determine that the
- variable is dynamically initialized in another module and
- issue a 1544 or 1545 as appropriate. However, the
- symbol referenced could be a function (as in the example)
- and PC-lint/FlexeLint does not analyze the complete
- function call graph to determine whether there is a
- dependency on another dynamic initialization. See also
- 1935 and 1937.
- 1937 Static variable 'Symbol' has a destructor. -- A static
- scalar whose name is Symbol has a destructor. Destructors
- of static objects are invoked in a predictable order only
- for objects within the same module (the reverse order of
- construction). For objects in different modules this
- order is indeterminate. Hence, if the correct operation
- of a destructor depends on the existence of an object in
- some other module an indeterminacy could result. See also
- 1935, 1936, 1544 and 1545.
- 1938 constructor 'Symbol' accesses global data. -- A
- constructor is accessing global data. It is generally not
- a good idea for constructors to access global data because
- order of initialization dependencies can be created. If
- the global data is itself initialized in another module
- and if the constructor is accessed during initialization,
- a 'race' condition is established. [12, Item 47]
- 1939 Down cast detected -- A down cast is a cast from a
- pointer (or reference) to a base class to a pointer (or
- reference) to a derived class. A cast down the class
- hierarchy is fraught with danger. Are you sure that the
- alleged base class pointer really points to an object in
- the derived class. Some amount of down casting is
- necessary but a wise programmer will reduce this to a
- minimum. [12, Item 39]
- 1961 virtual member function 'Symbol' could be made const --
- This message is similar to message 1762 (member function
- could be made const) except that it is issued for a
- virtual function. You may not want to make virtual
- functions const because then any overriding function would
- have to be const as well. Consider, for example:
- class A { virtual void f() {} /* ... */ };
- class B : public A
- { int a; void f() { a = 0; } };
- Here, class B overrides A's function f() and, in doing so,
- modifies member a. If A::f() had been declared const,
- this would not have been possible.
- Nonetheless, a particularly rigorous user may want to hunt
- down such virtual functions and make them all const and so
- this Note is provided.
- This message is also similar to Note 1962, which is
- issued for functions that make deep modifications. Note
- 1962 takes priority over 1961. That is, a virtual
- function that makes a deep modification (but no shallow
- modifications) will have Note 1962 issued but not Note 1961.
- 1962 Non-const member function 'Symbol' contains a deep
- modification. -- The designated member function could be
- declared const but shouldn't be because it contains a deep
- modification. For example:
- class X
- {
- char *p;
- public:
- void f() { *p = 0; }
- x();
- };
- will elicit this message indicating that X::f() contains a
- deep modification. A modification is considered shallow if
- it modifies (or exposes for modification) a class member
- directly. A modification is considered deep if it
- modifies information indirectly through a class member
- pointer. This Elective Note is available for completeness
- so that a programmer can find all functions that could
- result in a class being modified. It does not indicate
- that the programming is deficient. In particular, if the
- function is marked const an Info 1763 will be issued.
- See also 1762, 1763.