Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/test/AST/Interp/bitfields.cpp | ||
---|---|---|
37 | This is an interesting test case: struct A {int c:3;}; constexpr int f() { A a1{3}; return a1.c++; } void g() { constexpr int x = f(); } We are overflowing the bit-field value but it is implementation defined what the value is 😱 CC @aaron.ballman Might be worth checking the result of conditional operator and comma etc are bit-fields when they are supposed to be and therefore sizeof fails for those cases. |
Precommit CI is currently crashing on the newly introduced test case.
clang/test/AST/Interp/bitfields.cpp | ||
---|---|---|
37 | Yeah, the bit-field overflow case is http://eel.is/c++draft/expr.ass#4 -- we don't document what we do in this case (so this is a good opportunity to improve our docs), but we appear to treat it the same as overflow for a non-bit-field integer type: https://godbolt.org/z/4Ta7KoP58 |
It's missing https://reviews.llvm.org/D155548 :)
That's of course just a workaround. At the beginning of the evalute* fuctions in the new interpreter, there's a assert(S.Stk.empty()), to ensure that a previous interpret call didn't leave someting on the stack. But that doesn't work anymore since FieldDecl::getBitWidthValue() calls in the interpreter again while we're already evaluating something, so that assertion triggers.
Ah, I see, thank you for the explanation!
There's more work left here for supporting other operators and uses, but as far as these changes go, they seem reasonable to me. It'd be good to add Shafik's suggested test cases even if they're surrounded with FIXME comments, just so we don't lose track of the request.
This is an interesting test case:
We are overflowing the bit-field value but it is implementation defined what the value is 😱 CC @aaron.ballman
Might be worth checking the result of conditional operator and comma etc are bit-fields when they are supposed to be and therefore sizeof fails for those cases.