[Bug c/96293] Extraneously noisy "taking address of packed member may result in an unaligned pointer value"

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jul 27 11:15:59 GMT 2020


Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Your testcase is invalid, so it certainly deserves a warning.
One thing is that e.g. the int member is at offset 4, which is a multiple of
sizeof (int), but that doesn't help when the structure has alignment of 1 due
to packed, at which point the s variable doesn't have any alignment guarantees,
so (uintptr_t) &s.d % sizeof (int) can be any value from 0 to sizeof (int) - 1.

More information about the Gcc-bugs mailing list