3 ms·
It is just very finicky, with myriad edge cases easy to get wrong, and even easier to neglect to have complete tests for. Each target CPU design and version has
by ncmncm 5y ago
It is just very finicky, with myriad edge cases easy to get wrong, and even easier to neglect to have complete tests for. Each target CPU design and version has quirks. Many involve sign extension.
- jstimpfle 5y agoExtracting a subrange of bits and shifting them to the beginning is not exactly rocket science.
- ncmncm 5y agoExperience indicates otherwise. If you must use bit fields, make them unsigned. Bugs love to hide under signed bit fields.
- jstimpfle 5y agoThat makes sense, looking at how signed arithmetic works on different architectures it would feel strange to use signed bitfields. Unsigned bitfields are a nice way to get modular arithmetic with n bits without syntactic clutter.
- ncmncm 5y ago"Unsigned bitfields are a nice ..." Appear to be. Are, when all the stars align. Are not in fact, often enough that you are issued a red warning you may ignore if you are insulated from all consequences.