<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Intel documents these types as follows:<div class=""><br class=""></div><div class=""><span style="caret-color: rgb(102, 102, 102); color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">"The compiler aligns the </span><span class="keyword" style="box-sizing: border-box; font-family: "Courier New", Courier, monospace; caret-color: rgb(102, 102, 102); color: rgb(102, 102, 102); font-size: 13px;">__m256</span><span style="caret-color: rgb(102, 102, 102); color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">, </span><span class="keyword" style="box-sizing: border-box; font-family: "Courier New", Courier, monospace; caret-color: rgb(102, 102, 102); color: rgb(102, 102, 102); font-size: 13px;">__m256d</span><span style="caret-color: rgb(102, 102, 102); color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">, and </span><span class="keyword" style="box-sizing: border-box; font-family: "Courier New", Courier, monospace; caret-color: rgb(102, 102, 102); color: rgb(102, 102, 102); font-size: 13px;">__m256i</span><span style="caret-color: rgb(102, 102, 102); color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class=""> local and global data to 32-byte boundaries on the stack"</span><br class=""><div><br class=""></div><div>That’s awkwardly worded, but these types have 32B alignment; the result of casting a pointer that is not suitably aligned is undefined (i.e this is a bug in your code).</div><div><br class=""></div><div>– Steve</div><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 14, 2017, at 7:30 AM, Marcel Keller via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi,<br class=""><br class="">The attached code segfaults with clang 3.8 and 4.0:<br class=""><br class="">$ clang++ -g -O3 -mavx main.cpp A.cpp  ; ./a.out<br class="">Segmentation fault<br class=""><br class="">The problem is in the following line:<br class=""><br class="">    memset((__m256i*)dest, 0, length);<br class=""><br class="">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.<br class=""><br class="">Best regards,<br class="">Marcel<br class=""><span id="cid:084EE926-0789-49DB-B88B-AF8E99261483@hsd1.nh.comcast.net."><A.h></span><span id="cid:35BBA89C-9079-4906-8E4C-F7E7E4F3AD48@hsd1.nh.comcast.net."><main.cpp></span><span id="cid:9FA833EB-E4BD-47AE-90E1-AC1476E5982A@hsd1.nh.comcast.net."><A.cpp></span>_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></div></blockquote></div><br class=""></div></body></html>