admin 管理员组

文章数量: 1086019


2024年12月28日发(作者:manufacturer是什么主板)

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

.

1.11.31

-1937-

静态变量有一个析构函数

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

.

1.11.32

-1938-

构造函数访问全局数据容易造成矛盾

-- 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]

1.11.33

-1939-下转检测

是指从一个指向基类的指针到一个指向派生类的指针。

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

amount of down casting is necessary but a wise programmer will reduce this to a

minimum.[12, Item 39]

1.11.34

-1961-

虚成员函数是const类型

此告警信息和1762信息(成员函数是const类型)相似,除了它是虚函数之外。你不应该定

义虚函数为const类型,否则重新重载的函数也是const类型。如:

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 eless, a particularly rigorous user

may want to hunt down such virtual functions and make them all const and so this Note is

message is also similar to Note

1962

, which is issued for functions that make

deep

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.

1.11.35

-1962-

非const类型成员函数含有深度修改的代码

指定的成员函数能被声明为

const

类型但是不应该,因为包含了一个深度的修改。

例如:

class X

{

char *p;

public:

void f() { *p = 0; }

x();

};

如果X::f()含有深度修改代码,会产生此告警信息。如果它直接修改类成员被认为是比较浅

的修改。如果类成员指针间接修改类成员,被认为是深度修改。

This Elective Note is available

for completeness so that a programmer can find all functions that could result in a class being

modified. 它不是表示程序的不完善。特别的,如果函数被标识为

const

类型,信息

1763

将被issued. 参考信息

1762、1763

.


本文标签: 成员 函数 类型 修改