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
          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 
#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;
void set_to_max(char* abc) {
    *reinterpret_cast<__int128*>(abc) = ~((__int128)1 << 127);

when I execute following command
g++ -O3 -S

following asm code generated: 

        .file   ""
        .p2align 4,,15
        .globl  _Z10set_to_maxPc
        .type   _Z10set_to_maxPc, @function
        movdqa  .LC0(%rip), %xmm0
        movaps  %xmm0, (%rdi)
        .size   _Z10set_to_maxPc, .-_Z10set_to_maxPc
        .section        .rodata.cst16,"aM",@progbits,16
        .align 16
        .quad   -1
        .quad   9223372036854775807
        .ident  "GCC: (GNU) 7.3.0"
        .section        .note.GNU-stack,"",@progbits

movaps instruction cause the Segmentation fault

Reply via email to