Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

C++ checkers

Rule

araydecl

ARR02-CPP. Explicitly specify array bounds, even if implicitly defined by an initializer

araydecl

STR36-CPP. Do not specify the bound of a character array initialized with a string literal

bitftype

INT12-CPP. Do not make assumptions about the type of a plain int bit-field when used in an expression

callargs

EXP37-CPP. Call variadic functions with the arguments intended by the API

castexpr

EXP05-CPP. Do not use C-style casts

castexpr

EXP14-CPP. Do not use reinterpret_cast on pointers to class objects with multiple inheritence

castexpr

EXP35-CPP. Do not cast away a const qualification

castexpr

EXP36-CPP. Do not convert pointers into more strictly aligned pointer types

charcast

STR34-CPP. Cast characters to unsigned types before converting to larger integer sizes

charplan charsgnd

INT07STR04-CPP. Use only explicitly signed or unsigned plain char type for numeric valuesfor characters in the basic character set

cnstpnte

DCL00-CPP. Const-qualify immutable objects

cnstpnte

DCL13-CPP. Declare function parameters that are pointers to values not changed by the function as const

cplxcall

FLP31-CPP. Do not call functions expecting real values with complex values

declgrup_srceline

DCL04-CPP. Do not declare more than one variable per declaration

declhidn

DCL01-CPP. Do not reuse variable names in subscopes

declused

MSC22-CPP. Do not define static private members

dtrigraf

PRE07-CPP. Avoid using repeated question marks

enuminit

INT09-CPP. Ensure enumeration constants map to unique values

evalordr

EXP30-CPP. Do not depend on order of evaluation between sequence points

exprctxt

EXP19-CPP. Do not perform assignments in conditional expressions

exprprns

EXP00-CPP. Use parentheses for precedence of operation

exprprns

EXP17-CPP. Treat relational and equality operators as if they were nonassociative

filscope

DCL07-CPP. Minimize the scope of variables and methods

filscope

DCL15-CPP. Declare file-scope objects or functions that do not need external linkage in an unnamed namespace

floateql

FLP35-CPP. Take granularity into account when comparing floating point values

forcntrl

FLP30-CPP. Do not use floating point variables as loop counters

funcalls

EXP09-CPP. Use sizeof to determine the size of a type or variable

funcalls

MEM02-CPP. Immediately cast the result of a memory allocation function call into a pointer to the allocated type

hedrname

PRE04-CPP. Do not reuse a standard header file name

hedrname

PRE08-CPP. Guarantee that header file names are unique

idb_charplan

INT07-CPP. Use only explicitly signed or unsigned char type for numeric values

idb_charplan

STR37-CPP. Arguments to character handling functions must be representable as an unsigned char

idntsiml

DCL02-CPP. Use visually distinct identifiers

ignrtrn

EXP12-CPP. Do not ignore values returned by functions or methods

inclgard

PRE06-CPP. Enclose header files in an inclusion guard

ltrlsynt

DCL16-CPP. Use 'L', not 'l', to indicate a long value

macrbody

PRE01-CPP. Use parentheses within macros around parameter names

macrbody

PRE02-CPP. Macro replacement lists should be parenthesized

macrbody

PRE12-CPP. Do not define unsafe macros

macrcall

DCL03-CPP. Use a static assertion to test the value of a constant expression

macrcall

EXP31-CPP. Avoid side effects in assertions

macrcall

PRE00-CPP. Avoid defining macros

macrcall

PRE31-CPP. Avoid side-effects in arguments to unsafe macros

macrexpd

PRE03-CPP. Prefer typedefs to defines for encoding types

noeffect

MSC12-CPP. Detect and remove code that has no effect

minscope

DCL07-CPP. Minimize the scope of variables and methods

nomagicc

DCL06-CPP. Use meaningful symbolic constants to represent literal values in program logic

optrargs

INT13-CPP. Use bitwise operators only on unsigned operands

shiftrhs

INT34-CPP. Do not shift a negative number of bits or more bits than exist in the operand

stlibuse

ERR01-CPP. Use ferror() rather than errno to check for FILE stream errors

stlibuse

FIO07-CPP. Prefer fseek() to rewind()

stlibuse

FIO12-CPP. Prefer setvbuf() to setbuf()

stlibuse

MSC30-CPP. Do not use the rand() function for generating pseudorandom numbers

swchsynt

MSC18-CPP. Finish every set of statements associated with a case label with a break statement

swchsynt

MSC20-CPP. Do not use a switch statement to transfer control into a complex block

trycatch

ERR36-CPP. Multiple catch handlers to a try block should order their exceptions from most derived to most basic

unexfct

EXP06-CPP. Operands to the sizeof operator should not contain side effects

utypbtws

EXP15-CPP. Beware of integer promotion when performing bitwise operations on chars or shorts