-
Notifications
You must be signed in to change notification settings - Fork 37
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
Inconsistent Bitfield bitrange behavior #1489
Comments
I would actually expect But I'm wondering if there's a problem in the handling of MSB0: the way it works internally is that it first swaps the bit order of the whole integer value, the extracts the bits to yield the desired value. But that value is now in LSB0 order, so would it need to swap the bit order once more before continuing with the value? That would then yield the |
You're right about LSB0, it seems to be working as intended - my confusion. I see your point about how the bitfields operate - even though the location of each bit is different, the natures of MSB0 and LSB0 mean that the range starting at bit0 is built LSB first (right to left) for an LSB0 bitfield and MSB first (left to right) for an MSB0 bitfield. If the types containing the values respected bitorder, this would be fine, but since the type itself is LSB0 bitorder, the internal representation of the ranges becomes the same. I'm a bit confused about your explanation of how MSB0 is handled internally - if the bit order is swapped shouldn't the behavior of an LSB0 bitfield with
For MSB0, if the integer is flipped and then treated like a normal LSB0 bitfield: Integer passed into LSB0 bitfield: 1010 1010 Same Integer flipped, then passed into a regular LSB0 bitfield: 0101 0101 For MSB0, reversing the order of the input bits then treating them like a LSB0 bitfield seems like a good way of implementing the desired behavior, I'm not sure why it isn't working as implemented. |
I'll add this to our bitfield tracking ticket #1481 to take a closer look and double-check what we're doing currently. |
Note to self: Once this is settled, add a test that bitfield constants work as expected, per #1511 (comment). |
Running the following code results in the expected individual bit values based on the specified bit order, but unexpected bitrange values based on the specified bit order. Expected result for bitrange 0..7 in lsb bitfield is
55
.The text was updated successfully, but these errors were encountered: