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

evaluate -Wconditional-uninitialized #2056

Open
nickdesaulniers opened this issue Nov 5, 2024 · 3 comments
Open

evaluate -Wconditional-uninitialized #2056

nickdesaulniers opened this issue Nov 5, 2024 · 3 comments
Labels
question Question asked by issue author.

Comments

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Nov 5, 2024

This came up in an internal discussion, but we recently had a boogaloo because of some uninitialized value. It looks like clang could have caught that with -Wconditional-uninitialized, but:

  1. -Wconditional-uninitialized is not part of the -Wuninitialized group (surprising)
  2. The kernel doesn't enable -Wconditional-uninitialized.

I can't recall if we ever evaluated the use of this flag on the kernel or not. I'm curious if we can turn it on or if it has false positives?

Example: https://godbolt.org/z/4G7G5MjGa

@nickdesaulniers nickdesaulniers added the question Question asked by issue author. label Nov 5, 2024
@nathanchance
Copy link
Member

I recall looking into -Wconditional-uninitialized at one point in the past couple of years but from what I can tell, it suffers from many of the same pitfalls that -Wmaybe-uninitialized (GCC's version) has, which caused it to get disabled. It was quite noisy and most of the instances I saw appeared to be false positives.

@nickdesaulniers
Copy link
Member Author

It definitely caught an internal bug that -Wsometimes-uninitialized did not. I'm guessing it might have a measurable impact on compile times, but I did not measure.

@nickdesaulniers
Copy link
Member Author

I tested it quickly, and it seemed like this pattern had false positives:

int foo;
for (...)
  foo = 7;
use(foo);

Would flag in cases where it's not obvious that the loop body is ever executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question asked by issue author.
Projects
None yet
Development

No branches or pull requests

2 participants