Rules
- Rule 01. Declarations and Initialization (DCL)
- Rule 02. Expressions (EXP)
- Rule 03. Integers (INT)
- Rule 04. Containers (CTR)
- Rule 05. Characters and Strings (STR)
- Rule 06. Memory Management (MEM)
- Rule 07. Input Output (FIO)
- Rule 08. Exceptions and Error Handling (ERR)
- Rule 09. Object Oriented Programming (OOP)
- Rule 10. Concurrency (CON)
- Rule 49. Miscellaneous (MSC)
Information for Editors
To have a section listed above, label it section and rule .
Rule Listing
- AA. Bibliography
- BB. Definitions
- CON50-CPP. Do not destroy a mutex while it is locked
- CON51-CPP. Ensure actively held locks are released on exceptional conditions
- CON52-CPP. Prevent data races when accessing bit-fields from multiple threads
- CON53-CPP. Avoid deadlock by locking in a predefined order
- CON54-CPP. Wrap functions that can spuriously wake up in a loop
- CON55-CPP. Preserve thread safety and liveness when using condition variables
- CON56-CPP. Do not speculatively lock a non-recursive mutex that is already owned by the calling thread
- CTR50-CPP. Guarantee that container indices and iterators are within the valid range
- CTR51-CPP. Use valid references, pointers, and iterators to reference elements of a container
- CTR52-CPP. Guarantee that library functions do not overflow
- CTR53-CPP. Use valid iterator ranges
- CTR54-CPP. Do not subtract iterators that do not refer to the same container
- CTR55-CPP. Do not use an additive operator on an iterator if the result would overflow
- CTR56-CPP. Do not use pointer arithmetic on polymorphic objects
- CTR57-CPP. Provide a valid ordering predicate
- CTR58-CPP. Predicate function objects should not be mutable
- DCL50-CPP. Do not define a C-style variadic function
- DCL51-CPP. Do not declare or define a reserved identifier
- DCL52-CPP. Never qualify a reference type with const or volatile
- DCL53-CPP. Do not write syntactically ambiguous declarations
- DCL54-CPP. Overload allocation and deallocation functions as a pair in the same scope
- DCL55-CPP. Avoid information leakage when passing a class object across a trust boundary
- DCL56-CPP. Avoid cycles during initialization of static objects
- DCL57-CPP. Do not let exceptions escape from destructors or deallocation functions
- DCL58-CPP. Do not modify the standard namespaces
- DCL59-CPP. Do not define an unnamed namespace in a header file
- DCL60-CPP. Obey the one-definition rule
- ERR50-CPP. Do not abruptly terminate the program
- ERR51-CPP. Handle all exceptions
- ERR52-CPP. Do not use setjmp() or longjmp()
- ERR53-CPP. Do not reference base classes or class data members in a constructor or destructor function-try-block handler
- ERR54-CPP. Catch handlers should order their parameter types from most derived to least derived
- ERR55-CPP. Honor exception specifications
- ERR56-CPP. Guarantee exception safety
- ERR57-CPP. Do not leak resources when handling exceptions
- ERR58-CPP. Handle all exceptions thrown before main() begins executing
- ERR59-CPP. Do not throw an exception across execution boundaries
- ERR60-CPP. Exception objects must be nothrow copy constructible
- ERR61-CPP. Catch exceptions by lvalue reference
- ERR62-CPP. Detect errors when converting a string to a number
- EXP50-CPP. Do not depend on the order of evaluation for side effects
- EXP51-CPP. Do not delete an array through a pointer of the incorrect type
- EXP52-CPP. Do not rely on side effects in unevaluated operands
- EXP53-CPP. Do not read uninitialized memory
- EXP54-CPP. Do not access an object outside of its lifetime
- EXP55-CPP. Do not access a cv-qualified object through a cv-unqualified type
- EXP56-CPP. Do not call a function with a mismatched language linkage
- EXP57-CPP. Do not cast or delete pointers to incomplete classes
- EXP58-CPP. Pass an object of the correct type to va_start
- EXP59-CPP. Use offsetof() on valid types and members
- EXP60-CPP. Do not pass a nonstandard-layout type object across execution boundaries
- EXP61-CPP. A lambda object must not outlive any of its reference captured objects
- EXP62-CPP. Do not access the bits of an object representation that are not part of the object's value representation
- EXP63-CPP. Do not rely on the value of a moved-from object
- FIO50-CPP. Do not alternately input and output from a file stream without an intervening positioning call
- FIO51-CPP. Close files when they are no longer needed
- INT50-CPP. Do not cast to an out-of-range enumeration value
- MEM50-CPP. Do not access freed memory
- MEM51-CPP. Properly deallocate dynamically allocated resources
- MEM52-CPP. Detect and handle memory allocation errors
- MEM53-CPP. Explicitly construct and destruct objects when manually managing object lifetime
- MEM54-CPP. Provide placement new with properly aligned pointers to sufficient storage capacity
- MEM55-CPP. Honor replacement dynamic storage management requirements
- MEM56-CPP. Do not store an already-owned pointer value in an unrelated smart pointer
- MEM57-CPP. Avoid using default operator new for over-aligned types
- MSC50-CPP. Do not use std::rand() for generating pseudorandom numbers
- MSC51-CPP. Ensure your random number generator is properly seeded
- MSC52-CPP. Value-returning functions must return a value from all exit paths
- MSC53-CPP. Do not return from a function declared [[noreturn]]
- MSC54-CPP. A signal handler must be a plain old function
- OOP50-CPP. Do not invoke virtual functions from constructors or destructors
- OOP51-CPP. Do not slice derived objects
- OOP52-CPP. Do not delete a polymorphic object without a virtual destructor
- OOP53-CPP. Write constructor member initializers in the canonical order
- OOP54-CPP. Gracefully handle self-copy assignment
- OOP55-CPP. Do not use pointer-to-member operators to access nonexistent members
- OOP56-CPP. Honor replacement handler requirements
- OOP57-CPP. Prefer special member functions and overloaded operators to C Standard Library functions
- OOP58-CPP. Copy operations must not mutate the source object
- Rule 01. Declarations and Initialization (DCL)
- Rule 02. Expressions (EXP)
- Rule 03. Integers (INT)
- Rule 04. Containers (CTR)
- Rule 05. Characters and Strings (STR)
- Rule 06. Memory Management (MEM)
- Rule 07. Input Output (FIO)
- Rule 08. Exceptions and Error Handling (ERR)
- Rule 09. Object Oriented Programming (OOP)
- Rule 10. Concurrency (CON)
- Rule 49. Miscellaneous (MSC)
- STR50-CPP. Guarantee that storage for strings has sufficient space for character data and the null terminator
- STR51-CPP. Do not attempt to create a std::string from a null pointer
- STR52-CPP. Use valid references, pointers, and iterators to reference elements of a basic_string
- STR53-CPP. Range check element access