2 ms·
It sounds like the point you want to make is that the implementation of bitfields is often buggy, therefore you should always avoid using them - does that sound
by iainmerrick 5y ago
It sounds like the point you want to make is that the implementation of bitfields is often buggy, therefore you should always avoid using them - does that sound right?
If so, I think that’s overly paranoid. The examples that are being given here are baroque usage that would immediately stand out in a code review - memory-mapped registers, conditional lvalues, volatile and atomic fields.
The point I wanted to make is that simple straightforward usage of bitfields, like the example I gave, works fine on any platform you’re likely to encounter.
There’s plenty of widely-used code out there that uses bitfields. I just did a code search to check that (the particular example I was thinking of comes from iOS) and found some in Clang - funnily enough, in its representation of lvalues!