https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84525
Bug ID: 84525 Summary: GCC7: generate movaps instruction when assign to unaligned __int128* Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: buaa.zhaoc at gmail dot com Target Milestone: --- compiling the following code. Run the binary will cause a segment fault. GCC version is 7.3, Target: x86_64-pc-linux-gnu, Configure is ../gcc-7.3.0/configure CFLAGS=-O2 LDFLAGS=-static --enable-gold=yes --enable-languages=c,c++ --enable-c99 --enable-threads=posix --enable-__cxa_atexit --disable-multilib --disable-bootstrap g++ -O3 a.cc b.cc a.cc #include <iostream> extern void set_to_max(char* abc); int main() { char* abc = new char[100]; set_to_max(abc + 1); std::cout << (int64_t)(((*(__int128*)(abc+1))) >> 64) << std::endl; delete[] abc; return 0; } b.cc void set_to_max(char* abc) { *reinterpret_cast<__int128*>(abc) = ~((__int128)1 << 127); } when I execute following command g++ -O3 -S b.cc following asm code generated: .file "b.cc" .text .p2align 4,,15 .globl _Z10set_to_maxPc .type _Z10set_to_maxPc, @function _Z10set_to_maxPc: .LFB0: .cfi_startproc movdqa .LC0(%rip), %xmm0 movaps %xmm0, (%rdi) ret .cfi_endproc .LFE0: .size _Z10set_to_maxPc, .-_Z10set_to_maxPc .section .rodata.cst16,"aM",@progbits,16 .align 16 .LC0: .quad -1 .quad 9223372036854775807 .ident "GCC: (GNU) 7.3.0" .section .note.GNU-stack,"",@progbits movaps instruction cause the Segmentation fault