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.

assignIfError

Error prone
Informational

Mismatching assignment and comparison

badBitmaskCheck

Error prone
Error

Bad usage of bitmap operator

checkCastIntToCharAndBack

Error prone
Error

Storing getchar() return value in char variable and then comparing with EOF.

clarifyStatement

Error prone
Error

Misuse of ++ operator

class_X_Y

Error prone
Informational

Code not handled

comparisonOfBoolWithInvalidComparator

Error prone
Error

Comparison of a boolean value using relational operator (e.g. < ,>, etc)

coutCerrMisusage

Error prone
Critical

Invalid usage of output stream: '<< std::cout'.

derefInvalidIterator

Error prone
Critical

Possible dereference of an invalid iterator

eraseDereference

Error prone
Critical

Value used after being erased

fflushOnInputStream

Error prone
Warning

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

incorrectCharBooleanError

Error prone
Error

Conversion of char literal to bool always evaluates to true.

incorrectStringBooleanError

Error prone
Error

Incorrect string boolean operator

invalidContainer

Error prone
Critical

Invalid container

IOWithoutPositioning

Error prone
Critical

I/O operations without positioning

knownEmptyContainer

Error prone
Informational

Container is always empty

memsetZeroBytes

Error prone
Error

memset() called to fill 0 bytes.

redundantInitialization

Error prone
Informational

Redundant initialization. The initialized value is overwritten before it is read.

sizeofFunctionCall

Error prone
Error

Found function call inside sizeof().

sizeofVoid

Error prone
Warning

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

sizeofwithsilentarraypointer

Error prone
Error

Using 'sizeof' on array given as function argument returns size of a pointer.

stlIfFind

Error prone
Error

Suspicious condition. The result of find() is an iterator

truncLongCastReturn

Error prone
Informational

int result is returned as long value. If the return value is long to avoid loss of information

uselessCallsRemove

Error prone
Error

Return value ignored. Elements remain in container.

writeReadOnlyFile

Error prone
Critical

Write operation on a file that was opened only for reading.

wrongPrintfScanfParameterPositionError

Error prone
Error

printf: invalid parameter position

comparisonOfBoolWithBoolError

Error prone
Warning

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

nonStandardCharLiteral

Error prone
Informational

Non-standard character literal

rethrowNoCurrentException

Error prone
Warning

Rethrowing current exception

va_start_wrongParameter

Error prone
Error

Wrong parameter for va_start()

pureVirtualCall

Error prone
Warning

Call of pure virtual function in constructor.

We use cookies to improve your site experience, including analytics cookies to understand how you use our product and design better experiences. Please read our Cookie Policy.