-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
A false positive -Wmissing-field-initializers
for anonymous unions
#70444
Comments
@llvm/issue-subscribers-clang-frontend Author: Mariya Podchishchaeva (Fznamznon)
https://reviews.llvm.org/D157879 introduced a false positive for anonymous union members:
now produces a false positive warning saying that the anonymous union member in A is uninitialized. Thanks @zygoloid for reporting this. |
I gave it some thought.... Actually, should clang warn about it at all?
https://godbolt.org/z/7ev8Y95Y7 or should we not report something like this:
The latter asserts clang atm though. cc @AaronBallman @shafik for opinion. |
It seems like there is a lot of debate on this diagnostic: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96868#c3 I can see points on both sides of this discussion. There seems to be sufficient confusion that maybe we should have a separate diagnostic. |
Sure, but in general the warning does not warn on members with default member initializers, because in that case the initializer isn't missing -- it's present, in the class definition. In this case, there is a default member initializer.
This situation is different, because the author of struct
We shouldn't diagnose that under this warning flag. But we should warn that this is not valid C++ (anonymous unions can't be nested) and perhaps warn that it's pointless to nest them (flattening the two unions into one would change nothing). |
Duplicate. |
https://reviews.llvm.org/D157879 introduced a false positive for anonymous union members:
now produces a false positive warning saying that the anonymous union member in A is uninitialized.
Thanks @zygoloid for reporting this.
The text was updated successfully, but these errors were encountered: