Вы находитесь на странице: 1из 7

: : 09.12.2010 PVS-Studio / ++. , PVS-Studio, . PVS-Studio 4.00 , , . , / . , , . , . , . , . PVS-Studio, . 0 V501, #define. . i. , .

: #line 27 "C:\\Program Files (x86)\\Microsoft Visual Studio 8\\VC\\atlmfc\\include\\afx.h" , , , . , . , , , , , , "strcpy" . , . , ++ ++ , , , , . , PVS-Studio 4.00 , . ,

#line 1008 ".\\mytestfile.cpp" , , Visual Studio. i. i. . .

c/cpp, 1

, ,

V501. There are identical sub-expressions to the left and to the right of the 'foo' operator. , .
if (X > 0 && X > 0)

, . , . &&, ||, == &&. , . && : ,

if (A == A && B)

, . , '&&'. ,

'==' '==', &&, ,

. '==', :

if (A == 0 && A == 0)

. .
if ( '(' == A && '(' == B ) b = X > 0 && X > 0;

. . . , . .
if (Equal(left, right)) { // } !

, &&, ==, || : ,

. : b = '(' == x && x == ')';. 2

, .

V502. Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a lower priority than the 'foo' operator. , ).
int a; bool b; int c = a + b ? 0 : 1;

( :

. . . ( typedef. X , , , : . 3 V503. This is a nonsensical comparison: pointer < 0. .


CMeshBase *pMeshBase = getCutMesh(Idx); if (pMeshBase < 0) return NULL;

. , using namespace std;. : "auto X = 1 + 2;" C++0x. , , .

vector<int>::size_type.

? .

. / ++ . ,

<, >

, .

. pMeshBase.

4 V504. It is highly probable that the semicolon ';' is missing after 'return' keyword.
void Foo(); void Foo2(int *ptr) { if (ptr == NULL) return Foo(); ... }

. . void. , , .
int Foo() { ... char c[] = "void MyFoo(int x) {" ; ... }

, , . . , , : .

.
SimpleType funcReturnType; EFunctionReturnType fType;

, PVS-Studio):

if (!env->LookupFunctionReturnType(fType, funcReturnType)) return; if (funcReturnType != ST_VOID) return;

5 V505. The 'alloca' function is used inside the loop. This can quickly overflow stack. , , ,
{ for (int i = 0; i < 10; i++) { // char *x = " } p = _alloca(10); // } ? . { : -{"; . :)

. , . .

6 V506. Pointer to local variable 'X' is stored outside the scope of this variable. Such a pointer will become invalid. . . . 7 V507. Pointer to local array 'X' is stored outside the scope of this array. Such a pointer will become invalid. . 8 V508. The use of 'new type(n)' pattern was detected. Probably meant: 'new type[n]'. :
float *p = new float(10);

, ,
typedef float MyReal; ...

. :

MyReal *p = new MyReal(10);

. 9 V509. The 'throw' operator inside the destructor should be placed within the try..catch block. Raising exception inside the destructor is illegal. , , , , , ? . ? PVS-Studio ( ): , throw catch. . .

void ApplyRuleG_509(VivaWalker &walker, Environment *env, const Ptree *srcP tree) { SimpleType returnType; EFunctionReturnType fType; bool res = env ->LookupFunctionReturnType(fType, returnType); if (res == false || returnType != ST_UNKNOWN) return; if (fType != DESTRUCTOR) return;

ptrdiff_t tryLevel = OmpUtil ::GetLevel_TRY(env); if (tryLevel != -1) return; string error = VivaErrors::V509(); walker.AddError(error, srcPtree, 509, DATE_1_SEP_2010(), Level_1); }

10 V510. The 'Foo' function is not expected to receive class-type variable as 'N' actual argument.

printf . . .

std::string

, . PVS-Studio. , . ++ . . .

, , . , ,

Вам также может понравиться