[cfe-dev] Alignment assumptions
Marcel Keller via cfe-dev
cfe-dev at lists.llvm.org
Thu Dec 14 04:30:07 PST 2017
Hi,
The attached code segfaults with clang 3.8 and 4.0:
$ clang++ -g -O3 -mavx main.cpp A.cpp ; ./a.out
Segmentation fault
The problem is in the following line:
memset((__m256i*)dest, 0, length);
Removing the cast to __m256i* solves the problem. It seems that clang
assumes that __m256i* is always aligned correctly, which is not the case
in the code. Is that a bug in clang, or is that a mistake on my side?
GCC does not cause a segfault.
Best regards,
Marcel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A.h
Type: text/x-chdr
Size: 168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171214/e0745681/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 55 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171214/e0745681/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A.cpp
Type: text/x-c++src
Size: 145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171214/e0745681/attachment-0001.cpp>
More information about the cfe-dev
mailing list