-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 9626 |
| Resolution | FIXED |
| Resolved on | Apr 04, 2011 20:08 |
| Version | unspecified |
| OS | All |
| CC | @tkremenek |
Extended Description
This is partially my fault. =[ But I'm not sure what exactly to do here. I added a special check for -Wuninitialized with self-initialization cases. The recent changes to the CFG-based uninitialized checker now warn for the same construct, resulting in this:
% cat x.cc
void test() {
int x = x + 42;
(void)x;
}
% ./bin/clang -fsyntax-only -Wuninitialized x.cc
x.cc:2:11: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized]
int x = x + 42;
~ ^
x.cc:2:11: warning: variable 'x' is possibly uninitialized when used here [-Wuninitialized]
int x = x + 42;
^
x.cc:2:3: note: variable 'x' is declared here
int x = x + 42;
^
x.cc:2:17: note: add initialization to silence this warning
int x = x + 42;
^
= 0
2 warnings generated.
At the very least we shouldn't generate two warnings here, but more-over:
- The first is much more concise
- The declaration note is general unhelpful when warning on the initializer
- The fixit hint is just nuts here. =/
I wonder if we should stick to the custom logic for the initializer case for now? Or is there an easy way to fix these in the CFG?