[Bug c/99207] #pragma pack(1) and __int128 lead to bad optimization under O2 and higher optimization
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 22 17:10:40 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99207
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
CC| |jakub at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That is a user error, don't do that.
The fact that d doesn't point to properly aligned object needs to be visible on
the pointer dereference location, so you would need to use e.g. aligned(1)
attribute on e.g. a typedef to __int128, e.g.
typedef __int128 T __attribute__((aligned (1)));
T *d = &c.b;
Otherwise it is UB and -fsanitize=undefined would have diagnosed it.
More information about the Gcc-bugs
mailing list