https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83108
Bug ID: 83108 Summary: Unaligned 128bit dereference causes segfault with -O2 on x86-64 Product: gcc Version: 7.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: gcc-bugspam at coralbark dot net Target Milestone: --- Created attachment 42681 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42681&action=edit Preprocessed Source file If I have a __uint128_t *unalignedPtr Which points to an 8 byte (but not 16 byte) location then *unalignedPtr = 0; causes a seg fault on my x86-64 machine using: gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2) I'm attaching the example source file and the preprocessed source. I compile with (to see the problem): gcc -O2 128alignchk.c -o 128alignchk I've tried turning on individual optimisation to track down the problem but if I compile with: gcc -O1 -fthread-jumps -falign-functions -falign-jumps -falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively -fexpensive-optimizations -fgcse -fgcse-lm -fhoist-adjacent-loads -finline-small-functions -findirect-inlining -fipa-cp -fipa-bit-cp -fipa-vrp -fipa-sra -fipa-icf -fisolate-erroneous-paths-dereference -flra-remat -foptimize-sibling-calls -foptimize-strlen -fpartial-inlining -fpeephole2 -freorder-blocks-algorithm=stc -freorder-blocks-and-partition -freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec -fschedule-insns2 -fstore-merging -fstrict-aliasing -ftree-builtin-call-dce -ftree-switch-conversion -ftree-tail-merge -fcode-hoisting -ftree-pre -ftree-vrp -fipa-ra -fstrict-overflow -fvect-cost-model=cheap 128alignchk.c -o 128alignchk The resulting binary works fine (even though the output of -Q --help=optimizers is the same as with -O2).