Skip to content

Clang is not triggering -Wtautological-constant-compare when using -std=c23 #79435

@pileghoff

Description

@pileghoff

When compiling the minimal sample with any std flag (that i have tried) other than -std=c23, we get the warning:

warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]

This warning is not triggered for c23.

This regression was introduced somewhere between 14.0.0 and 15.0.0.

I have never worked with LLVM before, but i have decided to take a stab at solving the issue.

My initial hunch is that its related to the introduction of built in bools, as that seemed to be introduced in 15.0.0.

Minimal example

Godbolt

int test() {
  if (1 << 5) {
    return 0;
  }
  return 1;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    c23clang: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