-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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-optin.cplusplus.UninitializedObject
false positive with unnamed fields
#132001
Comments
@llvm/issue-subscribers-clang-static-analyzer Author: Oliver Stöneberg (firewave)
```cpp
struct S
{
S(bool b)
: b(b)
{}
bool b{false};
long long : 7; // padding
};
void f()
<source>:4:9: warning: 1 uninitialized field at the end of the constructor call [clang-analyzer-optin.cplusplus.UninitializedObject]
|
Hi! This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below. |
@llvm/issue-subscribers-good-first-issue Author: Oliver Stöneberg (firewave)
```cpp
struct S
{
S(bool b)
: b(b)
{}
bool b{false};
long long : 7; // padding
};
void f()
<source>:4:9: warning: 1 uninitialized field at the end of the constructor call [clang-analyzer-optin.cplusplus.UninitializedObject]
|
Probably somewhere in https://github.com/llvm/llvm-project/blob/main/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp we should check if the uninitialized field is an unnamed bitfield and bail out. |
@steakhal hey can you provide a bit more info on this issue and assign me I would like to work on it |
Hey, nice to see you interested. I'm not going to assign the issue, but it shouldn't matter. Feel free to work on this. So, the file that needs to be looked at is clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp, and probably the constructor of I don't know the actual implementation of this, but it shouldn't be difficult to follow. I trust you here. To run the tests, you can use the
Or
Once you have something, we can continue the discussion under a draft PR, at which point I'll assign this issue for you. |
@steakhal Here, are some of my findings and probable solution:
This is the backtrace while running
|
IDK the full context, but what you suggest matches my initial feeling. And this is why I tagged this with good first issue. I'm not sure about setting |
@steakhal for (const FieldDecl *I : RD->fields()) {
if (I->isUnnamedBitField()) {
IsAnyFieldInitialized = true;
continue;
}
......
} At this point, we only care about whether the current field is unnamed or not, and do not go deeper to determine whether the type of the field is legal or not, because this has already been done in Here are my test results: Total Discovered Tests: 989 |
Please submit a PR, and continue the discussion there. |
https://godbolt.org/z/7zzoK97x5
The text was updated successfully, but these errors were encountered: