facebook pixelCodiga Analysis C / C++ Rules, severity warning
BACK TO LIST

C / C++ rules

C and C++ are really performant languages and can be very error-prone. We all had core dumps and made pointer arithmetic errors! Thankfully, Codiga has hundreds of static analysis rules to flag potential errors in your C/C++ code, automate code reviews and merge with confidence.

arithOperationsOnVoidPointer

Best practice
Warning

Avoid arithmetic operation on void pointers

AssignmentAddressToInteger

Best practice
Warning

Assigning a pointer to an integer is not portable.

AssignmentIntegerToAddress

Security
Warning

Assigning an integer to a pointer is not portable.

CastAddressToIntegerAtReturn

Safety
Warning

Returning an address value in a function with integer return type is not portable.

CastIntegerToAddressAtReturn

Best practice
Warning

Returning an integer in a function with pointer return type is not portable.

fflushOnInputStream

Error prone
Warning

fflush() called on input stream may result in undefined behaviour on non-linux systems

invalidPointerCast

Best practice
Warning

Invalid pointer cast

memsetClassFloat

Safety
Warning

Using memset() on union which contains a floating point number.

noDestructor

Best practice
Warning

Class does not have a destructor which is recommended since it has dynamic memory/resource allocation(s).

passedByValue

Performance
Warning

Function parameter should be passed by const reference.

pointerOutOfBounds

Best practice
Warning

Undefined behaviour

postfixOperator

Performance
Warning

Prefer prefix ++/-- operators for non-primitive types.

shiftNegativeLHS

Best practice
Warning

Shifting a negative value is technically undefined behaviour

sizeofVoid

Error prone
Warning

Behaviour of 'sizeof(void)' is not covered by the ISO C standard.

stlcstrParam

Performance
Warning

Passing the result of c_str() to a function that takes std::string as argument no. 1 is slow and redundant.

stlcstrReturn

Performance
Warning

Returning the result of c_str() in a function that returns std::string is slow and redundant.

stlFindInsert

Performance
Warning

Searching before insertion is not necessary.

stlIfStrFind

Performance
Warning

Inefficient usage of string::find() in condition; string::starts_with() could be faster.

useInitializationList

Performance
Warning

Variable is assigned in constructor body. Consider performing initialization in initialization list.

uselessCallsSubstr

Performance
Warning

Ineffective call of function 'substr' because it returns a copy of the object. Use operator= instead.

varFuncNullUB

Best practice
Warning

Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.

comparisonOfBoolWithBoolError

Error prone
Warning

Comparison of a variable having boolean value using relational (<, >, <= or >=) operator

rethrowNoCurrentException

Error prone
Warning

Rethrowing current exception

pureVirtualCall

Error prone
Warning

Call of pure virtual function in constructor.