Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang false -Wtautological-unsigned-zero-compare warning. #125759

Open
pawelsopensource opened this issue Feb 4, 2025 · 0 comments
Open

clang false -Wtautological-unsigned-zero-compare warning. #125759

pawelsopensource opened this issue Feb 4, 2025 · 0 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-positive Warning fires when it should not

Comments

@pawelsopensource
Copy link

Hi, The following code triggers false positive warning about comparison < 0. The 'if limit ' shortcuts expression evaluation.

static constexpr unsigned limit = 0;

bool check( unsigned x ) {
    if ( limit && ( x < limit ) )
        return false;
    return true;
}

error: result of comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-unsigned-zero-compare]
     if ( limit && ( x < limit ) )
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Feb 4, 2025
@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-positive Warning fires when it should not and removed clang Clang issues not falling into any other category labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

3 participants