Text of codeql.github.com › codeql-query-help › cpp › cpp-unused-local-variable as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Unused local variable — CodeQL query help documentation

CodeQL query help documentation » CodeQL query help for C and C++ » Unused local variable ¶ ID: cpp/unused-local-variable Kind: problem Security severity: Severity: recommendation Precision: high Tags: - maintainability - useless-code - external/cwe/cwe-563 Query suites: - cpp-security-and-quality.qls Click to see the query in the CodeQL repository This rule finds local variables that are never accessed after declaration.

Unused variables should be removed to increase readability and avoid misuse. Recommendation ¶ Removing these unused local variables will make code more readable. Example ¶ { int x = 0 ; //x is unused int y = 0 ; cout << y ; } References ¶ Variable scope MSC12-C. Detect and remove code that has no effect Common Weakness Enumeration: CWE-563 . © GitHub, Inc. Terms Privacy