- Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Add cpp/uninitialized-local test #20407
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
Conversation
9d1dde7 to 2bc035c Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
| | ||
| too_many_constants_init(s); | ||
| | ||
| return m; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have an annotation here?
| return m; | |
| return m; // BAD -- m has not been initialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's GOOD actually. The initialization happens in the omitted too_many_constants_init.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| S s[] = { | ||
| {.a = 0, .c = 0, .d = nullptr, .r = {.n = {.e = e, .f = 1, .g = nullptr, .h = h, .i = i, .j = false, .k = k, .l = l, .m = &m}}}, | ||
| {.a = 0, .c = 0, .d = nullptr, .r = {.q = {.o = true, .p = true}}} | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice with a small comment explaining what the interesting thing being tested here is. Something with too many constants? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing anymore, after the extractor fix I merged yesterday. This test is just here to make sure we do not regress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then is is testing something interesting right? That we don't regress for some specific case. I'm suggesting it would be nice to write out what the special thing about this case here is. Is it the number of fields, the nesting, etc? It's not clear to me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to politely refuse, because this is related to internal extractor details. If you want the full story, please follow the link to the internal PR that references this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, I'm not suggesting writing anything about the extractor, but that we highlight the interesting/key aspect of the test. I've suggested a comment below.
| {.a = 0, .c = 0, .d = nullptr, .r = {.q = {.o = true, .p = true}}} | ||
| }; | ||
| | ||
| too_many_constants_init(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| too_many_constants_init(s); | |
| too_many_constants_init(s); // Initializer being passed a literal with many constants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you need to define what a constant is, because the aggregate here clearly isn't. Can we not go down this rabbit hole, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the problem, but ok.
No description provided.