SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
C++

C++ static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your C++ code

  • All rules 798
  • Vulnerability14
  • Bug173
  • Security Hotspot19
  • Code Smell592

  • Quick Fix 99
 
Tags
    Impact
      Clean code attribute
        1. "goto" should jump to labels declared later in the same function

           Code Smell
        2. The name "main" should not be used for any function other than the global "main" function

           Code Smell
        3. The global namespace should only contain "main", namespace declarations, and "extern" C declarations

           Code Smell
        4. Pointer and reference parameters should be "const" if the corresponding object is not modified

           Code Smell
        5. A variable which is not modified shall be const qualified

           Code Smell
        6. "<time.h>" should not be used

           Code Smell
        7. "abort", "exit", "getenv" and "system" from <stdlib.h> should not be used

           Bug
        8. "atof", "atoi" and "atol" from <stdlib.h> should not be used

           Bug
        9. "<stdio.h>" should not be used in production code

           Code Smell
        10. "<signal.h>" should not be used

           Bug
        11. "offsetof" macro should not be used

           Code Smell
        12. "errno" should not be used

           Code Smell
        13. Dynamic heap memory allocation should not be used

           Bug
        14. "setjmp" and "longjmp" should not be used

           Code Smell
        15. Reserved identifiers should not be defined or declared

           Code Smell
        16. Lines starting with "#" should contain valid preprocessing directives

           Bug
        17. Only standard forms of the "defined" directive should be used

           Code Smell
        18. Preprocessor operators "#" and "##" should not be used

           Code Smell
        19. There shall be at most one occurrence of the # or ## operators in a single macro definition

           Code Smell
        20. Macros used in preprocessor directives should be defined before use

           Bug
        21. In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##

           Code Smell
        22. Function-like macros should not be invoked without all of their arguments

           Bug
        23. Function-like macros should not be used

           Code Smell
        24. "#undef" should be used with caution

           Code Smell
        25. Macros should not be #define'd or #undef'd within a block

           Code Smell
        26. "#include" directives should be followed by either <filename> or "filename" sequences

           Bug
        27. Non-standard characters should not occur in header file names in "#include" directives

           Bug
        28. #include directives in a file should only be preceded by other preprocessor directives or comments

           Code Smell
        29. Unions should not be used

           Code Smell
        30. The address of an automatic object should not be assigned to another object that may persist after the first object has ceased to exist

           Bug
        31. Array type function arguments should not decay to pointers

           Code Smell
        32. Object declarations should contain no more than 2 levels of pointer indirection

           Code Smell
        33. Function names should be used either as a call with a parameter list or with the "&" operator

           Code Smell
        34. Function exit paths should have appropriate return values

           Bug
        35. Parameters in a function prototype should be named

           Code Smell
        36. Recursion should not be used

           Code Smell
        37. Loops should not have more than one "break" or "goto" statement

           Code Smell
        38. Functions should not be defined with a variable number of arguments

           Code Smell
        39. Evaluation of the operand to the sizeof operator shall not contain side effects

           Bug
        40. Switch statement conditions should not have essentially boolean type

           Code Smell
        41. The comma operator, "&&", and "||" should not be overloaded

           Code Smell
        42. Switch labels should not be nested inside non-switch blocks

           Code Smell
        43. The right-hand operands of && and || should not contain side effects

           Code Smell
        44. "continue" should not be used

           Code Smell
        45. "goto" statement should not be used

           Code Smell
        46. Non-empty statements should change control flow or have at least one side-effect

           Bug
        47. Unused type declarations should be removed

           Code Smell
        48. A loop-control-variable other than the loop-counter which is modified in statement shall have type bool

           Code Smell
        49. The loop-counter should be modified by one of: --, ++, -=n, or +=n; where n remains constant for the duration of the loop

           Code Smell
        50. The three expressions of a "for" statement should only be concerned with loop control

           Code Smell
        51. Increment (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression

           Code Smell
        52. Comma operator should not be used

           Code Smell
        53. The unary "&" operator should not be overloaded

           Code Smell
        54. Unary minus should not be applied to an unsigned expression

           Bug
        55. Bitwise operators should not be applied to signed operands

           Bug
        56. "enum" values should not be used as operands to built-in operators other than [ ], =, ==, !=, unary &, and the relational operators <, <=, >, >=

           Code Smell
        57. "bool" expressions should not be used as operands to built-in operators other than =, &&, ||, !, ==, !=, unary &, and the conditional operator

           Code Smell
        58. C-style and functional notation casts should not be used

           Code Smell
        59. Operands of "&&" and "||" should be primary (C) or postfix (C++) expressions

           Code Smell
        60. Boolean operations should not have numeric operands, and vice versa

           Bug
        61. Limited dependence should be placed on operator precedence

           Code Smell
        62. Objects with integer type should not be converted to objects with pointer type

           Bug
        63. A cast shall not remove any const or volatile qualification from the type of a pointer or reference

           Code Smell
        64. Pointer conversions should be restricted to a safe subset

           Bug
        65. Function pointers should not be converted to any other type

           Bug
        66. Constants of unsigned type should have a "U" suffix

           Code Smell
        67. Results of ~ and << operations on operands of underlying types unsigned char and unsigned short should immediately be cast to the operand's underlying type

           Bug
        68. Signed and unsigned types should not be mixed in expressions

           Code Smell
        69. "enum" members with implicit values should not collide with other enumerators

           Code Smell
        70. Variables should be initialized before use

           Bug
        71. Braces should be used to indicate and match the structure in the non-zero initialization of arrays and structures

           Code Smell
        72. Array declarations should include an explicit size specification

           Code Smell
        73. If a function has internal linkage then all re-declarations shall include the static storage class specifer

           Code Smell
        74. Objects or functions with external linkage shall be declared in a header file

           Code Smell
        75. Functions should not be declared at block scope

           Code Smell
        76. Non-standard attributes should not be used

           Code Smell
        77. MSVC-specific extensions should not be used

           Code Smell
        78. Code should not rely on features beyond the configured C++ standard

           Code Smell
        79. Literal suffix "L" for long integers shall be upper case

           Code Smell
        80. String literals with different prefixes should not be concatenated

           Bug
        81. Bit fields should be declared with appropriate types

           Code Smell
        82. typedefs that indicate size and signedness should be used in place of the basic types

           Code Smell
        83. The first operand of a conditional operator should have type bool

           Code Smell
        84. The condition of an if-statement and the condition of an iteration-statement shall have type bool

           Code Smell
        85. Appropriate char types should be used for character and integer values

           Code Smell
        86. Identifiers should not be longer than 31 characters

           Code Smell
        87. Digraphs should not be used

           Code Smell
        88. Trigraphs should not be used

           Code Smell
        89. Only escape sequences defined in the ISO C standard should be used

           Bug
        90. All uses of the #pragma directive should be documented

           Code Smell
        91. Source code should only use /* ... */ style comments

           Code Smell
        92. Assembly language should be encapsulated and isolated

           Code Smell
        93. Named methods should be used to avoid confusion between testing an optional or an expected and testing the wrapped value

           Code Smell
        94. std::string_view::data() should not be passed to API expecting C-style strings

           Code Smell
        95. String literals should not be assigned to mutable char pointers

           Code Smell
        96. "std::size" should be used to determine the size of arrays

           Code Smell
        97. Calls to c_str() should not implicitly recreate strings or string_views

           Code Smell
        98. Globals should not depend on possibly not yet initialized variables

           Code Smell
        99. String methods should be used to query content instead of C apis

           Code Smell
        100. The first element of an array should not be accessed implicitly

           Code Smell
        101. "std::views::as_const" should be used to prevent modifying range elements

           Code Smell
        102. Escape sequences should use the delimited form (\u{}, \o{}, \x{})

           Code Smell
        103. "std::stringstream" or "std::spanstream" should be used instead of "std::strstream"

           Code Smell
        104. The underlying value of an enum should be accessed through "to_underlying"

           Code Smell
        105. "contains" should be used to test whether a substring is part of a string

           Code Smell
        106. "if consteval" should be used instead of "if (std::is_constant_evaluated())"

           Code Smell
        107. The optional init-statement in a control statements should only be used to declare variables

           Code Smell
        108. The condition of "assert" should not be trivially true

           Code Smell
        109. A single L in a literal suffix should only be used for long values

           Code Smell
        110. "static_assert" should be preferred to assert when the argument is a compile-time constant

           Code Smell
        111. Macro arguments should not contain preprocessing directives

           Bug
        112. Names of well-known C standard library macros and functions should not be used as identifiers

           Code Smell
        113. Aggregates should be initialized with braces in non-generic code

           Code Smell
        114. All the elements of an aggregate should be provided with an initial value

           Code Smell
        115. Variables should not be accessed outside of their scope

           Bug
        116. Coroutines should have well-defined exception behavior

           Bug
        117. "constexpr" literal operators should be "consteval".

           Code Smell
        118. "std::format" should be used instead of standard output manipulators

           Code Smell
        119. C++ formatting functions should be used instead of C printf-like functions

           Code Smell
        120. The result of "make_format_args" should be passed directly as an argument

           Bug
        121. Use "std::format" rather than "std::vformat" when the format string is known at compile time

           Code Smell
        122. "std::format" numeric types should be 0-padded using the numerical padding and not the character padding

           Bug
        123. Arguments corresponding to width and precision formatting options should be integers

           Bug
        124. Calls to "std::format" with a locale should use the "L" flag

           Code Smell
        125. "std::format" should not have unused arguments

           Code Smell
        126. "std::format" should not be missing indexes

           Bug
        127. Concatenated "std::format" outputs should be replaced by a single invocation

           Code Smell
        128. Width, alignment, and padding format options should be used consistently

           Code Smell
        129. Explicit argument indexing in "std::format" should be used only for non-trivial ordering

           Code Smell
        130. Generic iterator-based algorithms should be constrained

           Code Smell
        131. "std::declval" should not be used within requires-expression

           Code Smell
        132. Template should not be constrained with ad-hoc requires-expression

           Code Smell
        133. Type-constraints should not be used for forwarding reference parameters

           Bug
        134. Perfect forwarding constructors should be constrained

           Bug
        135. Requires-expression should not contain unevaluated concept checks or type predicates

           Bug
        136. Assigning to an optional should directly target the optional

           Bug
        137. Hard-coded secrets are security-sensitive

           Security Hotspot
        138. Coroutines should not take const references as parameters

           Code Smell
        139. Use type-erased "coroutine_handle" when applicable

           Code Smell
        140. Coroutine should have co_return on each execution path or provide return_void

           Bug
        141. Thread local variables should not be used in coroutines

           Code Smell
        142. Use conditional suspension to resume current coroutine

           Code Smell
        143. Use symmetric transfer to switch execution between coroutines

           Code Smell
        144. The return value of "std::move" should be used in a function

           Code Smell
        145. rvalue reference members should not be copied accidentally

           Code Smell
        146. "auto" should be used to store a result of functions that conventionally return an iterator or a range

           Code Smell
        147. Well-defined type-punning method should be used instead of a union-based one

           Bug
        148. "std::string_view" and "std::span" parameters should be directly constructed from sequences

           Code Smell
        149. Comparision operators ("<=>", "==") should be defaulted unless non-default behavior is required

           Code Smell
        150. "std::chrono" components should be used to operate on time

           Code Smell
        151. "std::has_single_bit" should be used to test if an integer is a power of two

           Code Smell
        152. Empty class members should be marked as "[[no_unique_address]]"

           Code Smell
        153. "std::to_address" should be used to convert iterators to raw pointers

           Code Smell
        154. Result of the standard remove algorithms should not be ignored

           Bug
        155. "[[nodiscard]]" attributes on types should include explanations

           Code Smell
        156. Concept names should comply with a naming convention

           Code Smell
        157. "std::cmp_*" functions should be used to compare unsigned values with negative values

           Bug
        158. "volatile" should not be used to qualify objects for which the meaning is not defined

           Bug
        159. STL constrained algorithms with range parameter should be used when iterating over the entire range

           Code Smell
        160. "std::enable_if" should not be used

           Code Smell
        161. Cognitive Complexity of coroutines should not be too high

           Code Smell
        162. Coroutine names should comply with a naming convention

           Code Smell
        163. Cyclomatic Complexity of coroutines should not be too high

           Code Smell
        164. "volatile" types should not be used in compound operations

           Bug
        165. "std::source_location" should be used instead of "__FILE__", "__LINE__", and "__func__" macros

           Code Smell
        166. Function template parameters should be named if reused

           Code Smell
        167. "std::span" should be used for a uniform sequence of elements contiguous in memory

           Code Smell
        168. Operator spaceship "<=>" should be used to define comparable types

           Code Smell
        169. Redundant comparison operators should not be defined

           Code Smell
        170. "std::format" should be used instead of string concatenation and "std::to_string"

           Code Smell
        171. Coroutines should not have too many lines of code

           Code Smell
        172. "std::cmp_*" functions should be used to compare signed and unsigned values

           Code Smell
        173. "std::bit_cast" should be used to reinterpret binary representation instead of "std::memcpy"

           Code Smell
        174. "[[likely]]" and "[[unlikely]]" should be used instead of compiler built-ins

           Code Smell
        175. "std::midpoint" and "std::lerp" should be used for midpoint computation and linear interpolation

           Code Smell
        176. "starts_with" and "ends_with" should be used for prefix and postfix checks

           Code Smell
        177. "using enum" should be used in scopes with high concentration of "enum" constants

           Code Smell
        178. Designated initializers should be used in their C++ compliant form

           Code Smell
        179. "contains" should be used to check if a key exists in a container

           Code Smell
        180. "std::is_constant_evaluated" and "if consteval" should only be used when necessary

           Bug
        181. "std::jthread" should be used instead of "std::thread"

           Code Smell
        182. "nodiscard" attributes on functions should include explanations

           Code Smell
        183. Elements in a container should be erased with "std::erase" or "std::erase_if"

           Code Smell
        184. Mathematical constants should not be hardcoded

           Code Smell
        185. Use discriminated unions or "std::variant"

           Code Smell
        186. "sprintf" should not be used

           Security Hotspot
        187. Transparent function objects should be used with associative "std::string" containers

           Code Smell
        188. "emplace" should be prefered over "insert" with "std::set" and "std::unordered_set"

           Code Smell
        189. Unnecessary expensive copy should be avoided when using auto as a placeholder type

           Code Smell
        190. The right template argument should be specified for std::forward

           Code Smell
        191. "try_emplace" should be used with "std::map" and "std::unordered_map"

           Code Smell
        192. Exception specifications should be treated as part of the type

           Code Smell
        193. "auto" should be used for non-type template parameter

           Code Smell
        194. Use "std::variant" instead of unions with non-trivial types.

           Code Smell
        195. Free functions should be preferred to member functions when accessing a container in a generic context

           Code Smell
        196. "std::optional" member function "value_or" should be used

           Code Smell
        197. "std::byte" should be used when you need byte-oriented memory access

           Code Smell
        198. Heterogeneous sorted containers should only be used with types that support heterogeneous comparison

           Bug
        199. The "_t" and "_v" version of type traits should be used instead of "::type" and "::value"

           Code Smell
        200. Inline variables should be used to declare global variables in header files

           Code Smell
        201. "if constexpr" should be preferred to overloading for metaprogramming

           Code Smell
        202. "[*this]" should be used to capture the current object by copy

           Code Smell
        203. "std::uncaught_exception" should not be used

           Code Smell
        204. "static_assert" with no message should be used over "static_assert" with empty or redundant message

           Code Smell
        205. Redundant class template arguments should not be used

           Code Smell
        206. Objects should not be created solely to be passed as arguments to functions that perform delegated object creation

           Code Smell
        207. "std::filesystem::path" should be used to represent a file path

           Code Smell
        208. "std::string_view" should be used to pass a read-only string to a function

           Code Smell
        209. Fold expressions should be used instead of recursive template instantiations

           Code Smell
        210. [[nodiscard]] should be used when the return value of a function should not be ignored

           Code Smell
        211. "as_const" should be used to make a value constant

           Code Smell
        212. Structured binding should be used

           Code Smell
        213. "if" and "switch" initializer should be used to reduce scope of variables

           Code Smell
        214. Emplacement should be preferred when insertion creates a temporary with sequence containers

           Code Smell
        215. "std::visit" should be used to switch on the type of the current value in a "std::variant"

           Code Smell
        216. "std::scoped_lock" should be created with constructor arguments

           Bug
        217. "std::scoped_lock" should be used instead of "std::lock_guard"

           Code Smell
        218. "bind" should not be used

           Code Smell
        219. Changing working directories without verifying the success is security-sensitive

           Security Hotspot
        220. "dynamic_cast" should be used for downcasting

           Code Smell
        221. Multicharacter literals should not be used

           Code Smell
        222. Values returned from string find-related methods should not be treated as boolean

           Bug
        223. Struct should explicitly specify the access level when specifying base classes

           Code Smell
        224. Classes should explicitly specify the access level when specifying base classes

           Code Smell
        225. "std::initializer_list" constructor should not overlap with other constructors

           Code Smell
        226. Threads should not be detached

           Code Smell
        227. Loop variables should be declared in the minimal possible scope

           Code Smell
        228. "shared_ptr" should not be taken by rvalue reference

           Code Smell
        229. Inheriting constructors should be used

           Code Smell
        230. Return type of functions shouldn't be const qualified value

           Code Smell
        231. "make_unique" and "make_shared" should be used to construct "unique_ptr" and "shared_ptr"

           Code Smell
        232. "std::endl" should not be used

           Code Smell
        233. C-style array should not be used

           Code Smell
        234. Objects should not be sliced

           Bug
        235. Setting capabilities is security-sensitive

           Security Hotspot
        236. Accessing files should not introduce TOCTOU vulnerabilities

           Vulnerability
        237. Account validity should be verified when authenticating users with PAM

           Vulnerability
        238. "auto" should be used to avoid repetition of types

           Code Smell
        239. Macros should not be used as replacements for "typedef" and "using"

           Code Smell
        240. Using "tmpnam", "tmpnam_s" or "tmpnam_r" is security-sensitive

           Security Hotspot
        241. Integer literals should not be cast to bool

           Code Smell
        242. Member functions that don't mutate their objects should be declared "const"

           Code Smell
        243. Using "strncpy" or "wcsncpy" is security-sensitive

           Security Hotspot
        244. Using "strncat" or "wcsncat" is security-sensitive

           Security Hotspot
        245. Using "strcat" or "wcscat" is security-sensitive

           Security Hotspot
        246. Using "strlen" or "wcslen" is security-sensitive

           Security Hotspot
        247. Concise syntax should be used for concatenatable namespaces

           Code Smell
        248. Changing directories improperly when using "chroot" is security-sensitive

           Security Hotspot
        249. Using "strcpy" or "wcscpy" is security-sensitive

           Security Hotspot
        250. "memset" should not be used to delete sensitive data

           Vulnerability
        251. POSIX functions should not be called with arguments that trigger buffer overflows

           Vulnerability
        252. Relational and subtraction operators should not be used with pointers to different arrays

           Bug
        253. Track comments matching a regular expression

           Code Smell
        254. Arguments evaluation order should not be relied on

           Bug
        255. STL algorithms and range-based for loops should be preferred to traditional for loops

           Code Smell
        256. Immediately dangling references and pointers should not be created

           Bug
        257. Cipher algorithms should be robust

           Vulnerability
        258. Encryption algorithms should be used with secure mode and padding scheme

           Vulnerability
        259. Functions that are not used in a project should be removed

           Code Smell
        260. Server hostnames should be verified during SSL/TLS connections

           Vulnerability
        261. Multiple mutexes should not be acquired with individual locks

           Code Smell
        262. Local variables should be initialized immediately

           Code Smell
        263. Pointers or references obtained from aliased smart pointers should not be used as function parameters

           Code Smell
        264. "try_lock", "lock" and "unlock" should not be directly used for mutexes

           Code Smell
        265. A single statement should not have more than one resource allocation

           Code Smell
        266. "#pragma pack" should be used correctly

           Bug
        267. Function parameters that are rvalue references should be moved

           Code Smell
        268. Capture by reference in lambdas used locally

           Code Smell
        269. Size of bit fields should not exceed the size of their types

           Code Smell
        270. Enums should be consistent with the bit fields they initialize

           Bug
        271. "pthread_mutex_t" should be unlocked in the reverse order they were locked

           Bug
        272. Only valid arguments should be passed to UNIX/POSIX functions

           Code Smell
        273. "pthread_mutex_t" should be properly initialized and destroyed

           Bug
        274. "pthread_mutex_t" should not be locked when already locked, or unlocked when already unlocked

           Bug
        275. Only valid arguments should be passed to stream functions

           Code Smell
        276. Using publicly writable directories is security-sensitive

           Security Hotspot
        277. "Forwarding references" parameters should be used only to forward parameters

           Code Smell
        278. Functions should not have more than one argument of type "bool"

           Code Smell
        279. Non-const global variables should not be used

           Code Smell
        280. The order for arguments of the same type in a function call should be obvious

           Code Smell
        281. "std::move" and "std::forward" should not be confused

           Bug
        282. "using" should be preferred for type aliasing

           Code Smell
        283. "std::move" should only be used where moving can happen

           Code Smell
        284. Classes should not contain both public and private data members

           Code Smell
        285. Functions that throw exceptions should not be used as hash functions

           Code Smell
        286. "constexpr" functions should not be declared "inline"

           Code Smell
        287. A call to "wait()" on a "std::condition_variable" should have a condition

           Bug
        288. "^" should not be confused with exponentiation

           Code Smell
        289. Each operand of the ! operator, the logical && or the logical || operators shall have type bool

           Bug
        290. A cast should not convert a pointer type to an integral type

           Code Smell
        291. An object with integral type or pointer to void type shall not be converted to an object with pointer type

           Code Smell
        292. An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly

           Code Smell
        293. Pointer and reference local variables should be "const" if the corresponding object is not modified

           Code Smell
        294. Using clear-text protocols is security-sensitive

           Security Hotspot
        295. The identifiers used for the parameters in a re-declaration or override of a function shall be identical to those in the declaration

           Code Smell
        296. using-directives and using-declarations (excluding class scope or function scope using-declarations) shall not be used in header files

           Code Smell
        297. A loop-control-variable other than the loop-counter shall not be modified within condition or expression

           Code Smell
        298. Blocking functions should not be called inside critical sections

           Code Smell
        299. The loop-counter shall not be modified within condition or statement

           Code Smell
        300. If loop-counter is not modified by -- or ++, then, within condition, the loop-counter shall only be used as an operand to <=, <, > or >=

           Code Smell
        301. A for loop shall contain a single loop-counter which shall not have floating type

           Code Smell
        302. Every switch statement shall have at least one case-clause

           Code Smell
        303. Return value of "setuid" family of functions should always be checked

           Code Smell
        304. All "if ... else if" constructs shall be terminated with an "else "clause

           Code Smell
        305. An `if ( condition )` construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement

           Code Smell
        306. The statement forming the body of a "switch", "while", "do {...} while" or "for" statement shall be a compound statement

           Code Smell
        307. C-style casts (other than void casts) and functional notation casts (other than explicit constructor calls) shall not be used

           Code Smell
        308. A pointer to a virtual base class shall only be cast to a pointer to a derived class by means of dynamic_cast

           Bug
        309. When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization

           Bug
        310. GNU attributes should be used correctly

           Code Smell
        311. Format strings should comply with ISO standards

           Code Smell
        312. Size of variable length arrays should be greater than zero

           Code Smell
        313. Argument of "printf" should be a format string

           Code Smell
        314. "mktemp" family of functions templates should have at least six trailing "X"s

           Code Smell
        315. Unevaluated operands should not have side effects

           Code Smell
        316. Size argument of memory functions should be consistent

           Code Smell
        317. Return value of "nodiscard" functions should not be ignored

           Code Smell
        318. Implicit casts should not lower precision

           Code Smell
        319. "reinterpret_cast" should be used carefully

           Bug
        320. "std::move" should not inhibit optimizations

           Code Smell
        321. Appropriate size arguments should be passed to "strncat" and "strlcpy"

           Code Smell
        322. Moved-from objects should not be relied upon

           Code Smell
        323. Functions which do not return should be declared as "noreturn"

           Code Smell
        324. User-defined types should not be passed as variadic arguments

           Bug
        325. Class members should not be initialized with dangling references

           Bug
        326. Functions with "noreturn" attribute should not return

           Bug
        327. Keywords shall not be used as macros identifiers

           Code Smell
        328. Incomplete types should not be deleted

           Code Smell
        329. Logical operators should not be confused with bitwise operators

           Code Smell
        330. Dereferenced null pointers should not be bound to references

           Code Smell
        331. "else" statements should be clearly matched with an "if"

           Code Smell
        332. Header guards should be followed by a matching "#define" macro

           Code Smell
        333. Template parameters should be preferred to "std::function" when configuring behavior at compile time

           Code Smell
        334. Function pointers should not be used as function parameters

           Code Smell
        335. RAII objects should not be temporary

           Bug
        336. The addresses of standard library functions should not be taken

           Code Smell
        337. Expanding archive files without controlling resource consumption is security-sensitive

           Security Hotspot
        338. Macros should not be used to define constants

           Code Smell
        339. Memory should not be managed manually

           Code Smell
        340. Facilities in <random> should be used instead of "srand", "rand" and "random_shuffle"

           Code Smell
        341. Lambdas that capture "this" should capture everything explicitly

           Code Smell
        342. Move and swap operations should be "noexcept"

           Code Smell
        343. "void *" should not be used in typedefs, member variables, function parameters or return type

           Code Smell
        344. "memcmp" should only be called with pointers to trivially copyable types with no padding

           Bug
        345. "memcpy", "memmove", and "memset" should only be called with pointers to trivially copyable types

           Bug
        346. Function parameters should not be of type "std::unique_ptr<T> const &"

           Code Smell
        347. "std::auto_ptr" should not be used

           Bug
        348. The "Rule-of-Zero" should be followed

           Code Smell
        349. "nullptr" should be used to denote the null pointer

           Code Smell
        350. Server certificates should be verified during SSL/TLS connections

           Vulnerability
        351. Using weak hashing algorithms is security-sensitive

           Security Hotspot
        352. "default" clauses should be first or last

           Code Smell
        353. Cryptographic keys should be robust

           Vulnerability
        354. Weak SSL/TLS protocols should not be used

           Vulnerability
        355. "auto" should not be used to deduce raw pointers

           Code Smell
        356. Include directives should not rely on non-portable search strategy

           Code Smell
        357. Methods should not have identical implementations

           Code Smell
        358. Array values should not be replaced unconditionally

           Bug
        359. Method overloads should be grouped together in the interface

           Code Smell
        360. A conditionally executed single line should be denoted by indentation

           Code Smell
        361. Conditionals should start on new lines

           Code Smell
        362. Integral operations should not overflow

           Bug
        363. "case" ranges should cover multiple values

           Code Smell
        364. "case" ranges should not be empty

           Bug
        365. All branches in a conditional structure should not have exactly the same implementation

           Bug
        366. Parameter values should be appropriate

           Bug
        367. "#include" paths should be portable

           Code Smell
        368. "#import" should not be used

           Code Smell
        369. Cognitive Complexity of functions should not be too high

           Code Smell
        370. Macros should not be redefined

           Code Smell
        371. Exceptions should not be thrown in "noexcept" functions

           Code Smell
        372. 'extern "C"' should not be used with namespaces

           Code Smell
        373. "auto" should not be used as a storage class specifier

           Code Smell
        374. "#include_next" should not be used

           Code Smell
        375. Array indices should be placed between brackets

           Code Smell
        376. String literals should not be concatenated implicitly

           Code Smell
        377. "extern" shouldn't be used on member definitions

           Bug
        378. Virtual functions should not have default arguments

           Code Smell
        379. GNU extensions should not be used

           Code Smell
        380. Reference types should not be qualified with "const" or "volatile"

           Code Smell
        381. Non-exception types should not be caught

           Code Smell
        382. Non-exception types should not be thrown

           Code Smell
        383. Comparison operators should not be virtual

           Code Smell
        384. Partial specialization syntax should not be used for function templates

           Code Smell
        385. Declaration specifiers should not be redundant

           Bug
        386. Local variables should not be volatile

           Code Smell
        387. String literals should not be immediately followed by macros

           Code Smell
        388. Alternative operators should not be used

           Code Smell
        389. Assignment operators should not be "virtual"

           Code Smell
        390. Member variables should not be "protected"

           Code Smell
        391. Destructors should be "noexcept"

           Bug
        392. Types and variables should be declared in separate statements

           Code Smell
        393. Scoped enumerations should be used

           Code Smell
        394. "const" and "volatile" should not be used in "enum" declarations

           Code Smell
        395. "reinterpret_cast" should not be used

           Code Smell
        396. Raw string literals should be used

           Code Smell
        397. Classes should have regular copy and move semantic

           Code Smell
        398. "static" should not be used in unnamed namespaces

           Code Smell
        399. Default capture should not be used

           Code Smell
        400. Stack allocated memory and non-owned memory should not be freed

           Bug
        401. Closed resources should not be accessed

           Bug
        402. Dynamically allocated memory should be released

           Bug
        403. "final" classes should not have "virtual" functions

           Code Smell
        404. Redundant lambda return types should be omitted

           Code Smell
        405. "switch" statements should cover all cases

           Code Smell
        406. "inline" should not be used redundantly

           Code Smell
        407. Declarations of functions defined outside of the class should not be marked as "inline"

           Code Smell
        408. Standard groupings should be used with digit separators

           Code Smell
        409. Digit separators should be used

           Code Smell
        410. Allocation and deallocation functions should not be explicitly declared "static"

           Code Smell
        411. Base class access specifiers should not be redundant

           Code Smell
        412. Access specifiers should not be redundant

           Code Smell
        413. Freed memory should not be used

           Bug
        414. The "register" storage class specifier should not be used

           Code Smell
        415. Memory locations should not be released more than once

           Bug
        416. Memory access should be explicitly bounded to prevent buffer overflows

           Bug
        417. Zero should not be a possible denominator

           Bug
        418. Redundant pointer operator sequences should be removed

           Code Smell
        419. Special member function should not be defined unless a non standard behavior is required

           Code Smell
        420. "override" or "final" should be used instead of "virtual"

           Code Smell
        421. Standard namespaces should not be modified

           Code Smell
        422. Inheritance should be "public"

           Code Smell
        423. Function declarations that look like variable declarations should not be used

           Bug
        424. Empty "case" clauses that fall through to the "default" should be omitted

           Code Smell
        425. Format strings should be used correctly

           Code Smell
        426. Destructors should not be called explicitly

           Code Smell
        427. Conditional operators should not be nested

           Code Smell
        428. Namespaces should not be empty

           Code Smell
        429. "static" base class members should not be accessed via derived types

           Code Smell
        430. Forward declarations should not be redundant

           Code Smell
        431. Member data should be initialized in-class or in a constructor initialization list

           Code Smell
        432. Members should be initialized in the order they are declared

           Code Smell
        433. Label names should comply with a naming convention

           Code Smell
        434. "sizeof" should not be called on pointers

           Bug
        435. "this" should not be compared with null

           Code Smell
        436. "const" references to numbers should not be made

           Bug
        437. The "delete" operator should only be used for pointers

           Code Smell
        438. Binary operators should be overloaded as hidden friend functions

           Code Smell
        439. Bit fields should not be used

           Code Smell
        440. Unary prefix operators should not be repeated

           Bug
        441. Non-existent operators like "=+" should not be used

           Bug
        442. XML parsers should not be vulnerable to XXE attacks

           Vulnerability
        443. Declarations should not be empty

           Code Smell
        444. Values of different "enum" types should not be compared

           Bug
        445. General "catch" clauses should not be used

           Code Smell
        446. "catch" clauses should do more than rethrow

           Code Smell
        447. Multiline blocks should be enclosed in curly braces

           Code Smell
        448. Increment should not be used to set boolean variables to 'true'

           Code Smell
        449. The "sizeof" and "alignof" operator should not be used with operands of a "void" type

           Bug
        450. "nonnull" parameters and return values of "returns_nonnull" functions should not be null

           Bug
        451. Setting loose POSIX file permissions is security-sensitive

           Security Hotspot
        452. Conditionally executed code should be reachable

           Bug
        453. Exceptions should not be ignored

           Code Smell
        454. Control characters should not be used in literals

           Code Smell
        455. Child class fields should not shadow parent class fields

           Code Smell
        456. Enumeration values should comply with a naming convention

           Code Smell
        457. Enumeration names should comply with a naming convention

           Code Smell
        458. Octal and hexadecimal escape sequences should be terminated

           Code Smell
        459. Flexible array members should not be declared

           Code Smell
        460. Line-splicing should not be used in "//" comments

           Bug
        461. Standard C++ headers should be used

           Code Smell
        462. Namespace names should comply with a naming convention

           Code Smell
        463. Exception specifications should not be used

           Code Smell
        464. Printf-style format strings should not lead to unexpected behavior at runtime

           Bug
        465. Track parsing failures

           Code Smell
        466. Null pointers should not be dereferenced

           Bug
        467. User-specified functions should not be called

           Code Smell
        468. Using pseudorandom number generators (PRNGs) is security-sensitive

           Security Hotspot
        469. Parameters should be passed in the correct order

           Code Smell
        470. Single-bit named bit fields should not be of a signed type

           Bug
        471. "static" members should be accessed statically

           Code Smell
        472. "for" loop counters should not have essentially floating type

           Bug
        473. Recursion should not be infinite

           Bug
        474. "final" classes should not have "protected" members

           Code Smell
        475. Values should not be uselessly incremented

           Bug
        476. Member variables should be initialized

           Bug
        477. Resources should be closed

           Bug
        478. Hard-coded passwords are security-sensitive

           Security Hotspot
        479. "final" should not be used redundantly

           Code Smell
        480. Comment styles "//" and "/* ... */" should not be mixed within a file

           Code Smell
        481. Line continuation characters '\' should not be followed by trailing whitespace

           Bug
        482. Preprocessor directives should not be indented

           Code Smell
        483. Track instances of the "#error" preprocessor directive being reached

           Code Smell
        484. "sizeof(sizeof(...))" should not be used

           Bug
        485. Non-reentrant POSIX functions should be replaced with their reentrant versions

           Code Smell
        486. Obsolete POSIX functions should not be used

           Code Smell
        487. "goto" statements should not be used to jump into blocks

           Code Smell
        488. Redundant casts should not be used

           Code Smell
        489. "union" names should comply with a naming convention

           Code Smell
        490. Code annotated as deprecated should not be used

           Code Smell
        491. Two branches in a conditional structure should not have exactly the same implementation

           Code Smell
        492. Related "if/else if" statements should not have the same condition

           Bug
        493. Unused assignments should be removed

           Code Smell
        494. "switch" statements should not be nested

           Code Smell
        495. Structures should not have too many fields

           Code Smell
        496. The ternary operator should not be used

           Code Smell
        497. "public", "protected" and "private" sections of a class should be declared in that order

           Code Smell
        498. Constants should come first in equality tests

           Code Smell
        499. A "struct" should not have member functions

           Code Smell
        500. The sign of an unsigned variable should not be tested

           Code Smell
        501. Pointers should not be cast to integral types

           Bug
        502. Identical expressions should not be used on both sides of a binary operator

           Bug
        503. All code should be reachable

           Bug
        504. "#pragma warning (default: ...)" should not be used

           Code Smell
        505. Pre-defined macros should not be defined, redefined or undefined

           Code Smell
        506. Keywords introduced in later specifications should not be used as identifiers

           Code Smell
        507. Loops with at most one iteration should be refactored

           Bug
        508. Lambdas should not be used

           Code Smell
        509. Type specifiers should be listed in a standard order

           Code Smell
        510. Default parameters should not be defined

           Code Smell
        511. "explicit" should be used on single-parameter constructors and conversion operators

           Code Smell
        512. C++ comments should be used

           Code Smell
        513. Track "TODO" and "FIXME" comments that do not contain a reference to a person

           Code Smell
        514. Exceptions should not be used

           Code Smell
        515. The prefix increment/decrement form should be used

           Code Smell
        516. Virtual functions should not be called from constructors or destructors

           Code Smell
        517. The original exception object should be rethrown

           Bug
        518. Context-sensitive keywords should not be used as identifiers

           Code Smell
        519. Multiple variables should not be declared on the same line

           Code Smell
        520. Variables should not be self-assigned

           Bug
        521. "struct" names should comply with a naming convention

           Code Smell
        522. File names should comply with a naming convention

           Code Smell
        523. Macro names should comply with a naming convention

           Code Smell
        524. Cyclomatic Complexity of functions should not be too high

           Code Smell
        525. Unused local variables should be removed

           Code Smell
        526. "switch" statements should not have too many "case" clauses

           Code Smell
        527. Track lack of copyright and license headers

           Code Smell
        528. Classes should not have too many methods

           Code Smell
        529. Comments should not be located at the end of lines of code

           Code Smell
        530. Functions/methods should not have too many lines

           Code Smell
        531. Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply

           Code Smell
        532. Octal values should not be used

           Code Smell
        533. Using hardcoded IP addresses is security-sensitive

           Security Hotspot
        534. "switch" statements should have "default" clauses

           Code Smell
        535. "if" statements should be preferred over "switch" when simpler

           Code Smell
        536. Track uses of "NOSONAR" comments

           Code Smell
        537. Switch cases should end with an unconditional "break" statement

           Code Smell
        538. "::" operator should be used to access global variables and functions

           Code Smell
        539. Functions without parameters should not use "(void)"

           Code Smell
        540. "for" loop stop conditions should be invariant

           Code Smell
        541. "operator delete" should be written along with "operator new"

           Bug
        542. A "while" loop should be used instead of a "for" loop

           Code Smell
        543. "if ... else if" constructs should end with "else" clauses

           Code Smell
        544. "typedef" should be used for function pointers

           Code Smell
        545. Sections of code should not be commented out

           Code Smell
        546. Floating point numbers should not be tested for equality

           Bug
        547. Inherited functions should not be hidden

           Code Smell
        548. Pass by reference to const should be used for large input parameters

           Code Smell
        549. Assignment operators should return non-"const" reference to the assigned object

           Code Smell
        550. Polymorphic base class destructor should be either public virtual or protected non-virtual

           Code Smell
        551. Appropriate memory de-allocation should be used

           Bug
        552. C-style memory allocation routines should not be used

           Code Smell
        553. break statements should not be used except for switch cases

           Code Smell
        554. Statements should be on separate lines

           Code Smell
        555. "switch" statements should not contain non-case labels

           Code Smell
        556. Control structures should use curly braces

           Code Smell
        557. Nested code blocks should not be used

           Code Smell
        558. Lambdas should not have too many lines

           Code Smell
        559. Methods should not be empty

           Code Smell
        560. Overriding member functions should do more than simply call the same member in the base class

           Code Smell
        561. Generic exceptions should not be caught

           Code Smell
        562. Unused function parameters should be removed

           Code Smell
        563. Local variable and function parameter names should comply with a naming convention

           Code Smell
        564. Field names should comply with a naming convention

           Code Smell
        565. "empty()" should be used to test for emptiness

           Code Smell
        566. "switch case" clauses should not have too many lines of code

           Code Smell
        567. Unused functions and methods should be removed

           Code Smell
        568. Functions should not contain too many return statements

           Code Smell
        569. Try-catch blocks should not be nested

           Code Smell
        570. Track uses of "TODO" tags

           Code Smell
        571. Track uses of "FIXME" tags

           Code Smell
        572. Deprecated code should be removed

           Code Smell
        573. Lines should not end with trailing whitespaces

           Code Smell
        574. Files should end with a newline

           Code Smell
        575. Deprecated attributes should include explanations

           Code Smell
        576. Assignments should not be made from within conditions

           Code Smell
        577. Generic exceptions should never be thrown

           Code Smell
        578. Variables should not be shadowed

           Code Smell
        579. Empty statements should be removed

           Code Smell
        580. Redundant pairs of parentheses should be removed

           Code Smell
        581. "/*" and "//" should not be used within comments

           Code Smell
        582. Inheritance tree of classes should not be too deep

           Code Smell
        583. Magic numbers should not be used

           Code Smell
        584. Insecure functions should not be used

           Vulnerability
        585. Nested blocks of code should not be left empty

           Code Smell
        586. "scanf()" and "fscanf()" format strings should specify a field width for the "%s" string placeholder

           Vulnerability
        587. Functions should not have too many parameters

           Code Smell
        588. Unused "private" fields should be removed

           Code Smell
        589. Expressions should not be too complex

           Code Smell
        590. Mergeable "if" statements should be combined

           Code Smell
        591. Unused labels should be removed

           Code Smell
        592. Standard outputs should not be used directly to log anything

           Code Smell
        593. "<cstdio>" should not be used

           Code Smell
        594. "<ctime>" should not be used

           Code Smell
        595. C libraries should not be used

           Code Smell
        596. Tabulation characters should not be used

           Code Smell
        597. Destructors should not throw exceptions

           Bug
        598. Condition-specific "catch" handlers should not be used after the ellipsis (catch-all) handler

           Bug
        599. Handlers in a single try-catch or function-try-block for a derived class and some or all of its bases should be ordered most-derived-first

           Bug
        600. Exception classes should be caught by reference

           Bug
        601. Handlers of a function-try-block implementation of a class constructor or destructor shall not reference non-static members from this class or its bases

           Bug
        602. Files should not have too many lines of code

           Code Smell
        603. Empty throws ("throw;") should only be used in the compound statements of catch handlers

           Bug
        604. Control should not be transferred into a complex logic block using a "goto" or a "switch" statement

           Code Smell
        605. An exception object should not have pointer type

           Bug
        606. Function templates should not be specialized

           Code Smell
        607. Lines should not be too long

           Code Smell
        608. Pure "virtual" functions should not override non-pure "virtual" functions

           Code Smell
        609. Virtual functions should be declared with the "virtual" keyword

           Code Smell
        610. Accessible base classes should not be both "virtual" and non-virtual in the same hierarchy

           Bug
        611. Classes should not be derived from virtual bases

           Code Smell
        612. Class names should comply with a naming convention

           Code Smell
        613. Parameters in an overriding virtual function shall either use the same default arguments as the function they override, or else shall not specify any default arguments

           Code Smell
        614. A function should have a single point of exit at the end of the function

           Code Smell
        615. "using namespace" directives should not be used in header files

           Code Smell
        616. Multiple declarations for an identifier in the same namespace shall not straddle a using-declaration for that identifier

           Bug
        617. "using-directives" should not be used

           Code Smell
        618. Header files should not contain unnamed namespaces

           Code Smell
        619. Function names should comply with a naming convention

           Code Smell
        620. "Predicates" shall not have "persistent side effects"

           Bug
        621. The C++ Standard Library functions "memcpy", "memmove" and "memcmp" from "<cstring>" shall not be used

           Code Smell
        622. A function call shall not violate the function's preconditions

           Bug
        623. Floating-point arithmetic should be used appropriately

           Bug
        624. The character handling functions from "<cctype>" and "<cwctype>" shall not be used

           Code Smell
        625. The "goto" statement should not be used

           Code Smell
        626. An "integer-literal" of type "long long" shall not use a single "L" or "l" in any suffix

           Code Smell
        627. The literal value zero shall be the only value assigned to "errno"

           Code Smell
        628. A non-"transient lambda" shall not implicitly capture "this"

           Code Smell
        629. There shall be no occurrence of "undefined" or "critical unspecified behaviour"

           Bug
        630. User-defined identifiers shall have an appropriate form

           Code Smell
        631. "Legacy for statements" should be "simple"

           Code Smell
        632. A "for-range-initializer" shall contain at most one function call

           Bug
        633. "Global variables" shall not be used

           Code Smell
        634. The "volatile" qualifier shall be used appropriately

           Bug
        635. The built-in unary "+" operator should not be used

           Code Smell
        636. "Assignment" between numeric types shall be appropriate

           Code Smell
        637. "Integral promotion" and the "usual arithmetic conversions" shall not change the signedness or the "type category" of an operand

           Code Smell
        638. The operands of "bitwise operators" and "shift operators" shall be appropriate

           Bug
        639. There shall be no conversion to type "bool"

           Code Smell
        640. There shall be no conversion from type "bool"

           Code Smell
        641. The numerical value of a character shall not be used

           Code Smell
        642. "User-provided" copy and move member functions of a class should have appropriate signatures

           Code Smell
        643. "Special member functions" shall be provided appropriately

           Code Smell
        644. The argument to a "mixed-use macro parameter" shall not be subject to further expansion

           Code Smell
        645. An "object pointer type" shall not be cast to an integral type other than "std::uintptr_t" or "std::intptr_t"

           Code Smell
        646. The library function "system" from "<cstdlib>" shall not be used

           Vulnerability
        647. The pointers returned by the C++ Standard Library functions "localeconv", "getenv", "setlocale" or "strerror" must only be used as if they have pointer to const-qualified type

           Bug
        648. "Symmetrical operators" should only be implemented as non-member functions

           Code Smell
        649. "Exception-unfriendly" functions shall be "noexcept"

           Code Smell
        650. Member functions returning references to their object should be "ref-qualified" appropriately

           Code Smell
        651. An object shall not be accessed outside of its lifetime

           Bug
        652. A function declared with the "[[noreturn]]" attribute shall not return

           Bug
        653. If a project defines either a sized or unsized version of a global "operator delete", then both shall be defined

           Bug
        654. "std::vector" should not be specialized with "bool"

           Code Smell
        655. Variables of array type should not be declared

           Code Smell
        656. The "setlocale" and "std::locale::global" functions shall not be called

           Code Smell
        657. "User-provided" "copy assignment operators" and "move assignment operators" shall handle self-assignment

           Code Smell
        658. "User-declared" member functions shall use the "virtual", "override" and "final" specifiers appropriately

           Code Smell
        659. Derived classes shall not "conceal" functions that are inherited from their bases

           Code Smell
        660. A class shall only define an "initializer-list constructor" when it is the only constructor

           Code Smell
        661. "Unscoped enumerations" should not be declared

           Code Smell
        662. Functions with "limited visibility" should be "used" at least once

           Code Smell
        663. An "explicit type conversion" shall not be an "expression statement"

           Bug
        664. "Advanced memory management" shall not be used

           Code Smell
        665. Reads and writes on the same file stream shall be separated by a positioning operation

           Bug
        666. An argument passed via ellipsis shall have an appropriate type

           Bug
        667. Line-splicing shall not be used in "//" comments

           Bug
        668. A pointer to an incomplete "class" type shall not be deleted

           Bug
        669. All variables should be initialized

           Code Smell
        670. Octal escape sequences, hexadecimal escape sequences and universal character names shall be terminated

           Code Smell
        671. The result of "std::remove", "std::remove_if", "std::unique" and "empty" shall be "used"

           Bug
        672. The raw pointer constructors of "std::shared_ptr" and "std::unique_ptr" should not be used

           Code Smell
        673. An object shall not be used while in a "potentially moved-from state"

           Code Smell
        674. "Forwarding references" and "std::forward" shall be used together

           Code Smell
        675. The argument to "std::move" shall be a non-const "lvalue"

           Code Smell
        676. All direct, non-static data members of a class should be initialized before the class object is "accessible"

           Code Smell
        677. Dynamic memory shall be managed automatically

           Code Smell
        678. An enumeration shall be defined with an explicit underlying type

           Code Smell
        679. The "assert" macro shall not be used with a "constant-expression"

           Code Smell
        680. A comparison of a "potentially virtual" pointer to member function shall only be with "nullptr"

           Bug
        681. Variables should be captured explicitly in a non-"transient lambda"

           Code Smell
        682. Local variables shall not have static storage duration

           Code Smell
        683. Deprecated features should not be used

           Code Smell
        684. The C Library input/output functions shall not be used

           Code Smell
        685. The facilities provided by the standard "header file" "<csignal>" shall not be used

           Code Smell
        686. "Dynamic memory" should not be used

           Code Smell
        687. The macro "offsetof" shall not be used

           Code Smell
        688. The "string handling functions" from "<cstring>", "<cstdlib>", "<cwchar>" and "<cinttypes>" shall not be used

           Code Smell
        689. The pointer returned by the C++ Standard Library functions "asctime", "ctime", "gmtime", "localtime", "localeconv", "getenv", "setlocale" or "strerror" must not be used following a subsequent call to the same function

           Bug
        690. The library functions "atof", "atoi", "atol" and "atoll" from "<cstdlib>" shall not be used

           Bug
        691. The standard "header file" "<csetjmp>" shall not be used

           Code Smell
        692. The "#pragma" directive and the "_Pragma" operator should not be used

           Code Smell
        693. The "#" and "##" preprocessor operators should not be used

           Code Smell
        694. A macro parameter immediately following a "#" operator shall not be immediately followed by a "##" operator

           Code Smell
        695. The "#include" directive shall be followed by either a "<filename>" or ""filename"" sequence

           Bug
        696. The "'" or """ or "\" characters and the "/*" or "//" character sequences shall not occur in a "header file" name

           Bug
        697. Precautions shall be taken in order to prevent the contents of a "header file" being included more than once

           Code Smell
        698. All "#else", "#elif" and "#endif" preprocessor directives shall reside in the same file as the "#if", "#ifdef" or "#ifndef" directive to which they are related

           Code Smell
        699. The "defined" preprocessor operator shall be used appropriately

           Bug
        700. Program-terminating functions should not be used

           Code Smell
        701. A "noexcept" function should not attempt to propagate an exception to the calling function

           Bug
        702. An exception of "class" type shall be caught by "const" reference or reference

           Bug
        703. Handlers for a "function-try-block" of a constructor or destructor shall not refer to non-static members from their class or its bases

           Bug
        704. There should be at least one exception handler to catch all otherwise unhandled exceptions

           Bug
        705. An "empty throw" shall only occur within the "compound-statement" of a "catch handler"

           Code Smell
        706. An exception object shall not have pointer type

           Bug
        707. Function templates shall not be explicitly specialized

           Code Smell
        708. A name that is present in a dependent base shall not be resolved by unqualified lookup

           Code Smell
        709. Conversion operators and constructors that are callable with a single argument shall be "explicit"

           Code Smell
        710. All constructors of a class should explicitly initialize all of its virtual base classes and immediate base classes

           Code Smell
        711. An object's dynamic type shall not be used from within its constructor or destructor

           Code Smell
        712. Non-static data members should be either all "private" or all "public"

           Code Smell
        713. An accessible base class shall not be both virtual and non-virtual in the same hierarchy

           Bug
        714. Classes should not be inherited virtually

           Code Smell
        715. A named bit-field with "signed integer type" shall not have a length of one bit

           Bug
        716. A bit-field shall have an appropriate type

           Code Smell
        717. Bit-fields should not be declared

           Code Smell
        718. The "union" keyword shall not be used

           Code Smell
        719. Within an enumerator list, the value of an implicitly-specified "enumeration constant" shall be unique

           Code Smell
        720. The value of an object must not be read before it has been set

           Bug
        721. A conversion from function type to pointer-to-function type shall only occur in appropriate contexts

           Code Smell
        722. A function with non-"void" return type shall return a value on all paths

           Bug
        723. The parameters in all "declarations" or overrides of a function shall either be unnamed or have identical names

           Code Smell
        724. The features of "<cstdarg>" shall not be used

           Code Smell
        725. Parameters in an overriding virtual function shall not specify different default arguments

           Code Smell
        726. A "declaration" should not declare more than one variable or member variable

           Code Smell
        727. Functions shall not call themselves, either directly or indirectly

           Code Smell
        728. An assignment operator shall not assign the address of an object with automatic storage duration to an object with a greater lifetime

           Code Smell
        729. A function must not return a reference or a pointer to a local variable with automatic storage duration

           Bug
        730. The "asm" declaration shall not be used

           Code Smell
        731. There should be no unnamed namespaces in "header files"

           Code Smell
        732. The identifier "main" shall not be used for a function other than the global function "main"

           Code Smell
        733. The only "declarations" in the global namespace should be "main", namespace declarations and "extern "C"" declarations

           Code Smell
        734. The target type of a pointer or "lvalue" reference parameter should be const-qualified appropriately

           Code Smell
        735. The "goto" statement shall jump to a label declared later in the function body

           Code Smell
        736. A "goto" statement shall reference a label in a surrounding block

           Code Smell
        737. The structure of a "switch" statement shall be appropriate

           Code Smell
        738. All "if ... else if" constructs shall be terminated with an "else" statement

           Code Smell
        739. The body of an "iteration-statement" or a "selection-statement" shall be a "compound-statement"

           Code Smell
        740. The result of an assignment operator should not be "used"

           Code Smell
        741. An unsigned arithmetic operation with constant operands should not wrap

           Bug
        742. The comma operator should not be used

           Code Smell
        743. The right-hand operand of a logical "&&" or "||" operator should not contain "persistent side effects"

           Bug
        744. The operand to "typeid" shall not be an expression of polymorphic class type

           Code Smell
        745. The "address-of" operator shall not be overloaded

           Code Smell
        746. The built-in unary "-" operator should not be applied to an expression of unsigned type

           Bug
        747. An array passed as a function argument shall not decay to a pointer

           Code Smell
        748. The logical AND and logical OR operators shall not be overloaded

           Code Smell
        749. A cast should not convert a pointer type to an integral type

           Code Smell
        750. An object with integral, enumerated, or pointer to "void" type shall not be cast to a pointer type

           Code Smell
        751. "reinterpret_cast" shall not be used

           Code Smell
        752. Casts shall not be performed between a pointer to function and any other type

           Bug
        753. A cast shall not remove any "const" or "volatile" qualification from the type accessed via a pointer or by reference

           Code Smell
        754. C-style casts and "functional notation" casts shall not be used

           Code Smell
        755. A virtual base class shall only be cast to a derived class by means of "dynamic_cast"

           Bug
        756. The "declaration" of an object should contain no more than two levels of pointer indirection

           Code Smell
        757. The built-in relational operators ">", ">=", "<" and "<=" shall not be applied to objects of pointer type, except where they point to elements of the same array

           Bug
        758. Subtraction between pointers shall only be applied to pointers that address elements of the same array

           Bug
        759. Pointer arithmetic shall not form an invalid pointer

           Bug
        760. Parentheses should be used to make the meaning of an expression appropriately explicit

           Code Smell
        761. Operations on a memory location shall be sequenced appropriately

           Bug
        762. "nullptr" shall be the only form of the "null-pointer-constant"

           Code Smell
        763. The numeric value of an "unscoped enumeration" with no fixed "underlying type" shall not be used

           Code Smell
        764. The names of the "standard signed integer types" and "standard unsigned integer types" should not be used

           Code Smell
        765. The same type aliases shall be used in all "declarations" of the same "entity"

           Code Smell
        766. Internal linkage should be specified appropriately

           Code Smell
        767. A function or object with external linkage should be "introduced" in a "header file"

           Code Smell
        768. The source code used to implement an "entity" shall appear only once

           Bug
        769. The "one-definition rule" shall not be violated

           Bug
        770. All "declarations" of a variable or function shall have the same type

           Bug
        771. When an array with external linkage is declared, its size should be explicitly specified

           Code Smell
        772. Block scope "declarations" shall not be "visually ambiguous"

           Code Smell
        773. A "header file" shall not contain definitions of functions or objects that are non-inline and have external linkage

           Code Smell
        774. A line whose first token is "#" shall be a valid preprocessing directive

           Bug
        775. All identifiers used in the controlling expression of "#if" or "#elif" preprocessing directives shall be defined prior to evaluation

           Bug
        776. Parentheses shall be used to ensure macro arguments are expanded appropriately

           Code Smell
        777. Tokens that look like a preprocessing directive shall not occur within a macro argument

           Bug
        778. Function-like macros shall not be defined

           Code Smell
        779. "#undef" should only be used for macros defined previously in the same file

           Code Smell
        780. "#include" directives should only be preceded by preprocessor directives or comments

           Code Smell
        781. String literals with different encoding prefixes shall not be concatenated

           Bug
        782. The lowercase form of "L" shall not be used as the first character in a literal suffix

           Code Smell
        783. Unsigned "integer literals" shall be appropriately suffixed

           Code Smell
        784. Octal constants shall not be used

           Code Smell
        785. Within character literals and non raw-string literals, "\" shall only be used to form a defined escape sequence or universal character name

           Bug
        786. A variable declared in an "inner scope" shall not hide a variable declared in an "outer scope"

           Code Smell
        787. Sections of code should not be "commented out"

           Code Smell
        788. The character sequence "/*" shall not be used within a C-style comment

           Code Smell
        789. "Trigraph-like sequences" should not be used

           Code Smell
        790. A program shall conform to ISO/IEC 14882:2017 (C++17)

           Code Smell
        791. An object or subobject must not be copied to an overlapping object

           Bug
        792. A named function parameter shall be "used" at least once

           Code Smell
        793. The value returned by a function shall be "used"

           Code Smell
        794. A value should not be "unnecessarily written" to a local object

           Code Smell
        795. Types with "limited visibility" should be "used" at least once

           Code Smell
        796. Variables with "limited visibility" should be "used" at least once

           Code Smell
        797. Controlling expressions should not be invariant

           Bug
        798. A function shall not contain "unreachable" statements

           Bug

        When an array with external linkage is declared, its size should be explicitly specified

        intentionality - clear
        reliability
        Code Smell
        • pitfall
        • misra-c++2023
        • misra-advisory

        Why is this an issue?

        More Info

        This rule is part of MISRA C++:2023.

        Usage of this content is governed by Sonar’s terms and conditions. Redistribution is prohibited.

        Rule 6.0.2 - When an array with external linkage is declared, its size should be explicitly specified

        Category: Advisory

        Analysis: Decidable,Single Translation Unit

        Amplification

        This rule applies to non-defining declarations [1] only. It is possible to define an array and specify its size implicitly by means of initialization.

        Rationale

        Although it is possible to declare an array with incomplete type and access its elements, it is safer to do so when the size of the array may be explicitly determined. Providing size information for each declaration [1] permits them to be checked for consistency. It may also permit a static checker to perform some array bounds analysis without needing to analyse more than one translation unit.

        Example

               int32_t array1[ 10 ];                // Compliant
        extern int32_t array2[ ];                   // Non-compliant
               int32_t array3[ ] = { 0, 10, 15 };   // Compliant
        extern int32_t array4[ 42 ];                // Compliant
        

        Glossary

        [1] Declaration

        A declaration introduces the name of an entity into a translation unit (see [basic.def]/1).

        An entity may be declared several times. The first declaration of an entity in a translation unit is called an introduction [2]. All subsequent declarations are called redeclarations [3].

        A definition [4] is a declaration, as described in [basic.def]/2.

        [2] Introduction

        See declaration [1].

        [3] Redeclaration

        See declaration [1].

        [4] Definition

        See declaration [1].

        Copyright The MISRA Consortium Limited © 2023

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use