Skip to content

-Wconstant-logical-operand and yoda conditions #37919

@nickdesaulniers

Description

@nickdesaulniers
Bugzilla Link 38571
Version trunk
OS Linux
CC @gburgessiv,@lalozano,@m-gupta,@stephenhines

Extended Description

void foo(int x) {
    if (x && 5) {}
    if (5 && x) {}
}

The above produces -Wconstant-logical-operand for the first statement, but not the second.

This was observed while compiling the Linux kernel, as a single translation unit has a mix of which side the constant logical operand is on, but only some of the conditionals producing warnings. In these cases, the constant logical operand is nested a few macros deep.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions