6.2.12.9. FaultDetection

Static checks for possible runtime errors

Nested Rules

FaultDetection-AlternatingInputOutput

Alternate input and output operations shall not be used without an intervening flush or positioning call

FaultDetection-BadEnumValue

Only assign values corresponding to the enumerators to an expression of enumeration type

FaultDetection-BufferOverflow

The arguments to string handling functions from the Standard Library shall not result in accesses beyond the bounds of the objects referenced by their pointer arguments

FaultDetection-DeadBranches

There shall be no dead branches

FaultDetection-DeadCatch

There shall be no dead exception handlers

FaultDetection-DivisionByZero

Avoid division by zero

FaultDetection-DoubleFree

Do not release dynamically allocated memory twice

FaultDetection-EscapingLocalAddress

The address of a local variable should not escape its function

FaultDetection-ExceptionInsideThrow

The assignment-expression of a throw statement shall not itself cause an exception to be thrown

FaultDetection-ExceptionSpecificationViolation

Where a function’s declaration includes an exception-specification, the function shall only be capable of throwing exceptions of the indicated type(s)

FaultDetection-FileModeConflict

The same file shall not be open for read and write access at the same time on different streams

FaultDetection-ForbiddenOperations

When allocated in specific ways, some resource operations are forbidden

FaultDetection-FunctionMarker

Mark functions being (not) analysed by static semantic analysis

FaultDetection-IndirectAssignmentOverflow

Avoid overflow in indirect assignments

FaultDetection-IntegerOverflow

Avoid computations or casts resulting in integer overflow

FaultDetection-InvalidArgumentInCall

The validity of values passed to library functions shall be checked

FaultDetection-MemoryLeak

Do not forget to free allocated memory

FaultDetection-MissingRequiredOperations

When allocated in specific ways, some resource operations are required before deallocation

FaultDetection-NoexceptViolations

If a function is declared with noexcept(true) no exceptions should be thrown as this results in a call to std::terminate()

FaultDetection-NullPointerDereference

There shall be no attempt to dereference a null pointer

FaultDetection-OutOfBounds

Array index must be inside array bounds

FaultDetection-RemovableStatements

There shall be no statements that could be removed because they do not contribute to a function’s result

FaultDetection-StackFree

Do not release stack/static objects

FaultDetection-TaintAnalysis

The validity of values received from external sources shall be checked

FaultDetection-UncaughtExceptionEscapingMain

Each exception explicitly thrown in the code shall have a handler of a compatible type in all call paths that could lead to that point

FaultDetection-UncaughtExceptionInXtor

A class destructor shall not exit with an exception

FaultDetection-UncaughtExceptionOutsideMain

Exceptions shall be raised only after start-up and before termination of the program

FaultDetection-UninitializedVariable

Avoid accessing the value of an uninitialized variable

FaultDetection-UnrelatedPointerComparison

Avoid comparing unrelated pointers

FaultDetection-UnrelatedPointerSubtraction

Avoid pointer subtraction on unrelated pointers

FaultDetection-UnusedAssignments

A project shall not contain unused assignments

FaultDetection-UseAfterFree

Do not access memory locations after they have been released

FaultDetection-WrongReleaseFunction

Release dynamically allocated memory with appropriate function

Parallelism

Static checks for runtime errors due to parallelism

Options