[PATCH] D155270: [clang][Interp] Basic support for bit fields
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 1 07:43:44 PDT 2023
aaron.ballman added a comment.
Precommit CI is currently crashing on the newly introduced test case.
================
Comment at: clang/test/AST/Interp/bitfields.cpp:36
+ // TODO: +=, -=, etc. operators.
+}
----------------
shafik wrote:
> 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.
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
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155270/new/
https://reviews.llvm.org/D155270
More information about the cfe-commits
mailing list