Hi,
I’ve got a piece of C++ code that defines a struct with two bit fields. Clang is combining them into a single integer type, and I think: a) there must be a way to make it not do that, and b) there’s a bug in the process.
The code looks like:
enum enum_type1 {a, b, c};
enum enum_type2 {d, e, f};
struct bob {
enum_type1 foo : 64;
enum_type2 bar : 64;
}
When I examine the type information for a variable of type bob
, it shows a single field that is an i128. (Ftr: if I increase each field to 128 bits, I again get a single integer, this time with 256 bits; if there is a non-bit-field value in between the two bit fields, the two bit fields do not combine into a single integer.)
So that’s a) – is there a way (a flag, setting, etc.) to keep clang/llvm from combining the two bit fields into a single IntegerType?
And b) – for fun, I went into include/llvm/IR/DerivedTypes and set the maximum-allowed integer to 64 bits. This causes IntegerType:Get to fail its assertion that the size of a bit field be under the max – meaning, clang is automatically creating these large bit fields without first checking if they’ll go through the rest of the compiler, which seems like a bug…?
Thanks as usual,
Tim