[Bug c++/106873] unsigned short skips byte when used for memory mapping depending on position in structure
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Sep 7 16:45:01 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106873
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Kemal Akcam from comment #3)
> I did not report as if unsigned short was different than 2 bytes.
>
> Please check the output and explain
> 1. why output values changes?
> 2. why it reads/advances 10 bytes instead of 8 bytes?
Again you misunderstand everything. The ABI has a requirement for alignment of
some fields and that is what is called padding.
This is why I said you get a warning with -Wpadding .
If you want to remove this padding, you either use a bitfield or you use the
attribute packed.
More information about the Gcc-bugs
mailing list