https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120201
Bug ID: 120201
Summary: G++ generates a misaligned vector operation for
std::memcpy
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: stuart.a.hayhurst at gmail dot com
Target Milestone: ---
Created attachment 61385
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61385&action=edit
Reproducer
Creating a new bug, as instructed from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110027
Using GCC 14.2 or GCC 15.1 on Debian Sid, GCC is vectorising code with an
incorrect alignment as far as I can tell, only when using -fsanitize=address.
Compiling test.cpp with `g++ test.cpp -O3 -march=native -fsanitize=address
-std=c++23 -g`, I get a segfault when trying to execute it:
```
ratus5@snakeroot:~/Downloads$ ./a.out
AddressSanitizer:DEADLYSIGNAL
=================================================================
==31762==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x557263aa51eb bp
0x7ffedd5db760 sp 0x7ffedd5db4c0 T0)
==31762==The signal is caused by a READ memory access.
==31762==Hint: this fault was caused by a dereference of a high value address
(see register values below). Disassemble the provided pc to learn which
register was used.
#0 0x557263aa51eb in main /home/ratus5/Downloads/test.cpp:17
#1 0x7fb37de33ca7 in __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
#2 0x7fb37de33d64 in __libc_start_main_impl ../csu/libc-start.c:360
#3 0x557263aa62a0 in _start (/home/ratus5/Downloads/a.out+0x22a0) (BuildId:
71d0702639116c077ef5945e2e031492acefe9de)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/ratus5/Downloads/test.cpp:17 in main
==31762==ABORTING
```
Using GDB to inspect:
```
(gdb) run
Starting program: /home/ratus5/Downloads/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00005555555551eb in main () at test.cpp:22
22 std::memcpy(transformBlockStart + (matSize * face),
&transforms[face][0], matSize * sizeof(float));
(gdb) display /i $pc
1: x/i $pc
=> 0x5555555551eb <main()+219>: vmovdqa64 -0x1c0(%r12),%zmm0
(gdb) p $r12 % 64
$1 = 32
(gdb) exit
```