facebook pixelCodiga Analysis C / C++ Rules, severity error , category best practice
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.

accessMoved

Best practice
Error

Access of moved variable.

allocaCalled

Best practice
Error

Obsolete function 'alloca' called. In C99 and later it is recommended to use a variable length array instead.

arrayIndexOutOfBoundsCond

Best practice
Error

Array access out of bounds with a conditions

asctime_sCalled

Best practice
Error

Obsolete function 'asctime_s' called. It is recommended to use 'strftime' instead.

assertWithSideEffect

Best practice
Error

Assert statement calls a function which may have desired side effects: 'IsAddressInSegment'.

assignmentInAssert

Best practice
Error

Assert statement modifies variable

compareBoolExpressionWithInt

Best practice
Error

Comparison of a boolean expression with an integer other than 0 or 1.

constStatement

Best practice
Error

Detect unused variables

derefInvalidIteratorRedundantCheck

Best practice
Error

Condition is redundant or value is derefenced

exceptThrowInDestructor

Best practice
Error

Catching exception in destructor

funcArgOrderDifferent

Best practice
Error

Function not called with the right arguments

getsCalled

Best practice
Error

Obsolute function gets() called

identicalConditionAfterEarlyExit

Best practice
Error

Identical condition and return expression

identicalInnerCondition

Best practice
Error

Identical inner 'return' condition is always true.

ignoredReturnValue

Best practice
Error

Return value not used

incorrectLogicOperator

Best practice
Error

Logical conjunction always evaluates to false

integerOverflowCond

Best practice
Error

Integer overflow with condition

invalidLengthModifierError

Best practice
Error

Format string conversion error

invalidPrintfArgType_float

Best practice
Error

Invalid formatter for float

invalidPrintfArgType_sint

Best practice
Error

Invalid formatter for signed long long

invalidPrintfArgType_uint

Best practice
Error

Invalid formatter for unsigned int

invalidscanf

Best practice
Error

Invalid scanf

invalidScanfArgType_int

Best practice
Error

Invalid scanf for int

invalidTestForOverflow

Best practice
Error

Invalid test for overflow

literalWithCharPtrCompare

Best practice
Error

Direct string comparison. Compare with strcmp() instead

mismatchingContainerExpression

Best practice
Error

Iterators to containers from different expressions

negativeIndex

Best practice
Error

Negative index access

noCopyConstructor

Best practice
Error

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

noOperatorEq

Best practice
Error

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

nullPointerArithmeticRedundantCheck

Best practice
Error

Either the condition is redundant or there is overflow in pointer subtraction.

nullPointerRedundantCheck

Best practice
Error

Either the condition is redundant or there is possible null pointer dereference

objectIndex

Best practice
Error

The address of local variable might be accessed at non-zero index.

operatorEqToSelf

Best practice
Error

operator=' should check for assignment to self to avoid problems with dynamic memory.

operatorEqVarError

Best practice
Error

Member variable is not assigned a value

oppositeInnerCondition

Best practice
Error

Opposite inner 'return' condition leads to a dead code block.

pointerSize

Best practice
Error

Size of pointer used instead of size of its data.

redundantAssignInSwitch

Best practice
Error

Variable is reassigned a value before the old one has been used

seekOnAppendedFile

Best practice
Error

Repositioning operation performed on a file opened in append mode has no effect.

selfAssignment

Best practice
Error

Redundant assignment of variable to itself.

signConversion

Best practice
Error

Expression can have a negative value. That is converted to an unsigned value and used in an unsigned calculation.

sizeofCalculation

Best practice
Error

Calculation inside sizeof().

sizeofDivisionMemfunc

Best practice
Error

Division by result of sizeof(). memset() expects a size in bytes

staticStringCompare

Best practice
Error

Unnecessary comparison of static strings.

uninitMemberVar

Best practice
Error

Member variable not initialized in the constructor.

uninitMemberVarPrivate

Best practice
Error

Member private variable is not initialized in the constructor.

uselessAssignmentPtrArg

Best practice
Error

Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?

uselessCallsEmpty

Best practice
Error

Ineffective call of function 'empty()'. Call 'clear()' instead.

virtualCallInConstructor

Best practice
Error

Dynamic binding is not used.

mismatchingBitAnd

Best practice
Error

Mismatching bitmasks.

returnStdMoveLocal

Best practice
Error

Using std::move for returning object by-value from function will affect copy elision optimization

Learn more