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-analyzer-core.UndefinedBinaryOperatorResult false-postive #112527

Open
nick-potenski opened this issue Oct 16, 2024 · 1 comment
Open

clang-analyzer-core.UndefinedBinaryOperatorResult false-postive #112527

nick-potenski opened this issue Oct 16, 2024 · 1 comment
Labels
clang:static analyzer false-positive Warning fires when it should not

Comments

@nick-potenski
Copy link

The clang-analyzer-core.UndefinedBinaryOperatorResult incorrectly assumes an std::array's size() function can return 0 when used as the condition in a for loop with an index even though the array's size is a compile-time constant. This causes the analysis to skip the loop's body and leads to a false-positive uninitialized variable. I have a simplified reproduction case in Compiler Explorer here: https://godbolt.org/z/jGb3dv1qP

@EugeneZelenko EugeneZelenko added clang:static analyzer false-positive Warning fires when it should not and removed new issue labels Oct 16, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 16, 2024

@llvm/issue-subscribers-clang-static-analyzer

Author: Nick Potenski (nick-potenski)

The `clang-analyzer-core.UndefinedBinaryOperatorResult` incorrectly assumes an std::array's size() function can return 0 when used as the condition in a for loop with an index even though the array's size is a compile-time constant. This causes the analysis to skip the loop's body and leads to a false-positive uninitialized variable. I have a simplified reproduction case in Compiler Explorer here: https://godbolt.org/z/jGb3dv1qP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:static analyzer false-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

3 participants