Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Unclear comparison precedence

ID: cpp/comparison-precedenceKind: problemSecurity severity: Severity: warningPrecision: very-highTags:   - maintainability   - readabilityQuery suites:   - cpp-security-and-quality.qls

Click to see the query in the CodeQL repository

This rule finds comparison expressions that use 2 or more comparison operators and are not completely parenthesized. It is best to fully parenthesize complex comparison expressions to explicitly define the order of the comparison operators.

Recommendation

Fully parenthesize complex comparison expressions to avoid confusion.

Example

voidh(){inta,b,c;a<b!=c;//parenthesize to explicitly define order of operators(a<b)<c;//correct: parenthesized to specify order}

References


[8]ページ先頭

©2009-2025 Movatter.jp