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 420
  • Vulnerability14
  • Bug111
  • Security Hotspot19
  • Code Smell276

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

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

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

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

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

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

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

           Bug
        8. "offsetof" macro should not be used

           Code Smell
        9. "errno" should not be used

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

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

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

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

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

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

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

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

           Bug
        18. 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
        19. Function-like macros should not be invoked without all of their arguments

           Bug
        20. Function-like macros should not be used

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

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

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

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

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

           Code Smell
        26. Unions should not be used

           Code Smell
        27. Structure and union types should be complete at the end of a translation unit

           Code Smell
        28. 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
        29. Object declarations should contain no more than 2 levels of pointer indirection

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

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

           Bug
        32. The number of arguments passed to a function should match the number of parameters

           Bug
        33. Functions without parameters should be declared with parameter type "void"

           Code Smell
        34. Parameters in a function prototype should be named

           Code Smell
        35. Recursion should not be used

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

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

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

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

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

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

           Code Smell
        42. "continue" should not be used

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

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

           Bug
        45. Unused type declarations should be removed

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

           Code Smell
        47. Tests of non-Boolean values against zero should be explicit

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

           Code Smell
        49. Comma operator should not be used

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

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

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

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

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

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

           Bug
        56. Limited dependence should be placed on operator precedence

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

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

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

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

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

           Code Smell
        62. 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
        63. The value of a complex expression should only be cast to a type that is narrower and of the same signedness as the underlying type of the expression

           Code Smell
        64. Signed and unsigned types should not be mixed in expressions

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

           Code Smell
        66. Variables should be initialized before use

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

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

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

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

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

           Code Smell
        72. Object and function types should be explicitly stated in their declarations and definitions

           Code Smell
        73. Functions should be declared explicitly

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

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

           Bug
        76. Bit fields should be declared with appropriate types

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

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

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

           Code Smell
        80. Digraphs should not be used

           Code Smell
        81. Trigraphs should not be used

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

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

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

           Code Smell
        85. Assembly language should be encapsulated and isolated

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

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

           Code Smell
        88. Macro arguments should not contain preprocessing directives

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

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

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

           Bug
        92. Hard-coded secrets are security-sensitive

           Security Hotspot
        93. "volatile" should not be used to qualify objects for which the meaning is not defined

           Bug
        94. "sprintf" should not be used

           Security Hotspot
        95. Changing working directories without verifying the success is security-sensitive

           Security Hotspot
        96. Multicharacter literals should not be used

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

           Code Smell
        98. Setting capabilities is security-sensitive

           Security Hotspot
        99. Accessing files should not introduce TOCTOU vulnerabilities

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

           Vulnerability
        101. Macros should not be used as replacements for "typedef" and "using"

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

           Security Hotspot
        103. Using "strncpy" or "wcsncpy" is security-sensitive

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

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

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

           Security Hotspot
        107. Changing directories improperly when using "chroot" is security-sensitive

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

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

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

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

           Bug
        112. Track comments matching a regular expression

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

           Bug
        114. Cipher algorithms should be robust

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

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

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

           Vulnerability
        118. "#pragma pack" should be used correctly

           Bug
        119. Size of bit fields should not exceed the size of their types

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

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

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

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

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

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

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

           Security Hotspot
        127. "^" should not be confused with exponentiation

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

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

           Security Hotspot
        130. Blocking functions should not be called inside critical sections

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

           Code Smell
        132. GNU attributes should be used correctly

           Code Smell
        133. Format strings should comply with ISO standards

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

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

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

           Code Smell
        137. Unevaluated operands should not have side effects

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

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

           Code Smell
        140. Implicit casts should not lower precision

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

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

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

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

           Bug
        145. Keywords shall not be used as macros identifiers

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

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

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

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

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

           Security Hotspot
        151. "memcmp" should only be called with pointers to trivially copyable types with no padding

           Bug
        152. Server certificates should be verified during SSL/TLS connections

           Vulnerability
        153. Using weak hashing algorithms is security-sensitive

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

           Code Smell
        155. Cryptographic keys should be robust

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

           Vulnerability
        157. Include directives should not rely on non-portable search strategy

           Code Smell
        158. Array values should not be replaced unconditionally

           Bug
        159. A conditionally executed single line should be denoted by indentation

           Code Smell
        160. Conditionals should start on new lines

           Code Smell
        161. Integral operations should not overflow

           Bug
        162. "case" ranges should cover multiple values

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

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

           Bug
        165. Parameter values should be appropriate

           Bug
        166. "#include" paths should be portable

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

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

           Code Smell
        169. Macros should not be redefined

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

           Code Smell
        171. Array indices should be placed between brackets

           Code Smell
        172. String literals should not be concatenated implicitly

           Code Smell
        173. GNU extensions should not be used

           Code Smell
        174. Declaration specifiers should not be redundant

           Bug
        175. Local variables should not be volatile

           Code Smell
        176. Types and variables should be declared in separate statements

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

           Bug
        178. Closed resources should not be accessed

           Bug
        179. Dynamically allocated memory should be released

           Bug
        180. "switch" statements should cover all cases

           Code Smell
        181. Freed memory should not be used

           Bug
        182. Memory locations should not be released more than once

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

           Bug
        184. Zero should not be a possible denominator

           Bug
        185. Redundant pointer operator sequences should be removed

           Code Smell
        186. Empty "case" clauses that fall through to the "default" should be omitted

           Code Smell
        187. Format strings should be used correctly

           Code Smell
        188. Conditional operators should not be nested

           Code Smell
        189. Forward declarations should not be redundant

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

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

           Bug
        192. Bit fields should not be used

           Code Smell
        193. Unary prefix operators should not be repeated

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

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

           Vulnerability
        196. Declarations should not be empty

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

           Bug
        198. Multiline blocks should be enclosed in curly braces

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

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

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

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

           Security Hotspot
        203. Conditionally executed code should be reachable

           Bug
        204. Control characters should not be used in literals

           Code Smell
        205. The "<stdlib.h>" functions "bsearch" and "qsort" should not be used

           Bug
        206. Enumeration values should comply with a naming convention

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

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

           Code Smell
        209. Flexible array members should not be declared

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

           Bug
        211. Printf-style format strings should not lead to unexpected behavior at runtime

           Bug
        212. Track parsing failures

           Code Smell
        213. Null pointers should not be dereferenced

           Bug
        214. User-specified functions should not be called

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

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

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

           Bug
        218. "for" loop counters should not have essentially floating type

           Bug
        219. Recursion should not be infinite

           Bug
        220. Values should not be uselessly incremented

           Bug
        221. Resources should be closed

           Bug
        222. Hard-coded passwords are security-sensitive

           Security Hotspot
        223. Comment styles "//" and "/* ... */" should not be mixed within a file

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

           Bug
        225. Preprocessor directives should not be indented

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

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

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

           Code Smell
        229. Obsolete POSIX functions should not be used

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

           Code Smell
        231. Redundant casts should not be used

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

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

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

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

           Bug
        236. Unused assignments should be removed

           Code Smell
        237. "restrict" should not be used

           Code Smell
        238. "static" should not be used for the size of an array parameter

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

           Code Smell
        240. Structures should not have too many fields

           Code Smell
        241. The ternary operator should not be used

           Code Smell
        242. Constants should come first in equality tests

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

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

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

           Bug
        246. All code should be reachable

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

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

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

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

           Bug
        251. Type specifiers should be listed in a standard order

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

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

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

           Code Smell
        255. Variables should not be self-assigned

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

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

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

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

           Code Smell
        260. Unused local variables should be removed

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

           Code Smell
        262. Track lack of copyright and license headers

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

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

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

           Code Smell
        266. Octal values should not be used

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

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

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

           Code Smell
        270. Track uses of "NOSONAR" comments

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

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

           Code Smell
        273. A "while" loop should be used instead of a "for" loop

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

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

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

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

           Bug
        278. break statements should not be used except for switch cases

           Code Smell
        279. Function parameters' initial values should not be ignored

           Bug
        280. Statements should be on separate lines

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

           Code Smell
        282. Control structures should use curly braces

           Code Smell
        283. Nested code blocks should not be used

           Code Smell
        284. Deprecated K&R syntax should not be used for function definition

           Code Smell
        285. Methods should not be empty

           Code Smell
        286. Unused function parameters should be removed

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

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

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

           Code Smell
        290. Unused functions and methods should be removed

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

           Code Smell
        292. Track uses of "TODO" tags

           Code Smell
        293. Track uses of "FIXME" tags

           Code Smell
        294. Deprecated code should be removed

           Code Smell
        295. Lines should not end with trailing whitespaces

           Code Smell
        296. Files should end with a newline

           Code Smell
        297. Deprecated attributes should include explanations

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

           Code Smell
        299. Variables should not be shadowed

           Code Smell
        300. Empty statements should be removed

           Code Smell
        301. Redundant pairs of parentheses should be removed

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

           Code Smell
        303. Magic numbers should not be used

           Code Smell
        304. Insecure functions should not be used

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

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

           Vulnerability
        307. Functions should not have too many parameters

           Code Smell
        308. Expressions should not be too complex

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

           Code Smell
        310. Unused labels should be removed

           Code Smell
        311. Tabulation characters should not be used

           Code Smell
        312. Files should not have too many lines of code

           Code Smell
        313. Control should not be transferred into a complex logic block using a "goto" or a "switch" statement

           Code Smell
        314. Lines should not be too long

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

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

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

           Bug
        318. Floating-point arithmetic should be used appropriately

           Bug
        319. The "goto" statement should not be used

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

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

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

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

           Code Smell
        324. "Global variables" shall not be used

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

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

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

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

           Bug
        329. The argument to a "mixed-use macro parameter" shall not be subject to further expansion

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

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

           Vulnerability
        332. 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
        333. Functions with "limited visibility" should be "used" at least once

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

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

           Bug
        336. All variables should be initialized

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

           Code Smell
        338. Dynamic memory shall be managed automatically

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

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

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

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

           Code Smell
        343. 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
        344. The standard "header file" "<csetjmp>" shall not be used

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

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

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

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

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

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

           Code Smell
        351. 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
        352. The "defined" preprocessor operator shall be used appropriately

           Bug
        353. Program-terminating functions should not be used

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

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

           Code Smell
        356. Bit-fields should not be declared

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

           Bug
        376. The comma operator should not be used

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

           Bug
        378. The built-in unary "-" operator should not be applied to an expression of unsigned type

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

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

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

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

           Code Smell
        383. The "declaration" of an object should contain no more than two levels of pointer indirection

           Code Smell
        384. 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
        385. Subtraction between pointers shall only be applied to pointers that address elements of the same array

           Bug
        386. Pointer arithmetic shall not form an invalid pointer

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

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

           Bug
        389. The names of the "standard signed integer types" and "standard unsigned integer types" should not be used

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

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

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

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

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

           Bug
        395. Block scope "declarations" shall not be "visually ambiguous"

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

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

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

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

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

           Bug
        401. Function-like macros shall not be defined

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

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

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

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

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

           Code Smell
        407. Octal constants shall not be used

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

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

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

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

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

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

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

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

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

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

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

           Code Smell
        419. Controlling expressions should not be invariant

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

           Bug

        The "#pragma" directive and the "_Pragma" operator should not be used

        intentionality - complete
        maintainability
        Code Smell
        • lock-in
        • 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 19.6.1 - The #pragma directive and the _Pragma operator should not be used

        [cpp.pragma] Implementation 1
        [cpp.pragma.op] 1

        Category: Advisory

        Analysis: Decidable, Single Translation Unit

        Rationale

        The effects of the #pragma directive and the _Pragma operator are implementation-defined.

        Example

        #pragma once                    // Non-compliant
        
        #define P( x ) _Pragma( #x )    // Non-compliant
        
        _Pragma( "once" )               // Non-compliant
        

        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