Skip to content

-Wconstant-logical-operand regression with comparison operators in C2x mode with Clang 17 #64356

Closed
@porglezomp

Description

@porglezomp

Basic programs involving constant comparisons produce -Wconstant-logical-operand with -std=c2x but not with -std=c17.
This program shouldn't produced -Wconstant-logical-operand because my understanding is that's for using boolean operations with integer operands, but these should both be booleans.
This is happening only in trunk and the clang 17 release, neither one produces the warning in clang 16.

(This program is reduced from a program with a constant sizeof comparison that was failing.)

int main(int argc, const char **argv) {
    if ((1 == 1) && (argc == 1)) return 1;
    return 0;
}

Godbolt link demonstrating the regression: https://godbolt.org/z/e15rEc6r9

Metadata

Metadata

Assignees

No one assigned

    Labels

    c23clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerregression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions