Bare Metal C++ Register Access API
allthingsembedded.com
allthingsembedded.com
The author does mention some of this but their conclusion is misguided: it’s not a portability problem, it’s a showstopper. Indeed, the next point release of the exact same compiler could very well decide to use a completely different behavior for bitfield.
Any seasoned low-level engineer would know: bitfields should never be used for register mapping, period. I wish the article made that more explicit.
arm-none-eabi-gcc changing its behavior for bitfields would probably break 99% of existing arm MCU codebases.
It explains pitfalls in accessing these through low level C definitions, proposes a C++ encapsulation class and summarizes pros and cons.