Fixed an overflow error in field_size#3
Fixed an overflow error in field_size#3KevinNelsonPlexus wants to merge 3 commits intoKKoovalsky:mainfrom
Conversation
|
Sorry, for such a late response. Busy times at work ;) I understand that there is a compilation error here, but I find having one field only, which occupies the entire bitfield structure, not needed. Actually, it's good that there is a compilation error: maybe we should make the I might not see a use case here. Could you give an example why the user would like to use the structure for one field occupying the entire structure? |
|
No worries! I thought I would just contribute what I found. I end up using it in automatically generated code. In my case, portable bitfields wraps a FPGA register which can sometimes be a single field. Rather than having a different interface for these specific registers, and needing extra complexity in the code generation, I just tweaked the library to allow this case. |
|
I could merge it, but it's missing the runtime tests against https://github.com/KKoovalsky/PortableBitfields/blob/main/tests/test_extracting.cpp#L77
Would you be willing to extend the test cases? Best regards, |
|
I suggest adding the static_cast fix from this PR to this PR. |
|
@nate-plxs would you be willing to extend the test cases as mentioned in my comment above? |
There is an overflow in field_size which causes a compiler error. This occurs in the special case where a single field is defined which is the same width as the underlying type. Added a check to handle this edge case, and tests to verify.