-
Notifications
You must be signed in to change notification settings - Fork 11.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
[16.0.0, 2022-11-02 ToT] Assertion `Field->isUnnamedBitfield() && "Only unnamed bitfields allowed"' failed. #58800
Comments
And here's the files: |
@llvm/issue-subscribers-clang-codegen |
Confirmed godbolt: https://godbolt.org/z/vvGExj9Y7 |
I spent a little bit of time looking at this and I believe having in class member initialization changed the paths we can take to get here and make the assumptions not valid anymore. Salvaging it may require some heroics but not sure. |
It looks like we are ending up at So it looks like adjusting the assertion like this: assert((Field->isUnnamedBitfield() || Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or anonymous struct allowed"); would fix this case. I was not able to hit this path through other means. |
@AaronBallman wdyt this is a GNU extension and gcc accepts the code: https://godbolt.org/z/KjM3o4hdK so I think my analysis based on that is correct and extending the assert is the right thing. |
I think your analysis is reasonable; both GCC and ICC accept that code, and I think Clang should as well. |
…pr to cover anonymous struct in a union GNU extension AggExprEmitter::VisitInitListExpr sanity checks that an empty union is really empty and not a semantic analysis failure. The assert is missing that we allow anonymous structs as a GNU extension. I have updated the assert to take that into account. This fixes: llvm/llvm-project#58800 Differential Revision: https://reviews.llvm.org/D139261
…pr to cover anonymous struct in a union GNU extension AggExprEmitter::VisitInitListExpr sanity checks that an empty union is really empty and not a semantic analysis failure. The assert is missing that we allow anonymous structs as a GNU extension. I have updated the assert to take that into account. This fixes: llvm/llvm-project#58800 Differential Revision: https://reviews.llvm.org/D139261
Obviously only reproduces on a build with asserts (
-DLLVM_ENABLE_ASSERTIONS=On
)This is at HEAD from yesterday (40e9947), but given that this assertion has been sitting around for a while (2009! 5169570), maybe not a recent regression. I don't have older assert-enabled builds of clang to debug against.
Simple reproducer:
Removing the brace-initializers reveals that the default constructor is implicitly deleted, which seems probably related.
Easy fix for users, simply declare a default constructor for the object:
struct Foo { + Foo() {} union { struct { float red = 0.0f; }; }; };
The text was updated successfully, but these errors were encountered: