<div dir="ltr"><div style="font-size:13px">I just find a serious bug. Windows prebuilt binary.</div><div style="font-size:13px">------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-------------</div><div style="font-size:13px">#include <stdio.h></div><div style="font-size:13px">#include <intrin.h></div><div style="font-size:13px"><br></div><div style="font-size:13px">//this function is just copyed from `intrin.h': __movsb(), __x86_64__</div><div style="font-size:13px">static __inline__ void __attribute__((__always_<wbr>inline__, __nodebug__))</div><div style="font-size:13px">__movsb_buggy(unsigned char *__dst, unsigned char const *__src, size_t __n) {</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>//for(size_t i=0; i<__n; i++) __dst[i] = __src[i]; //OK</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>__asm__("rep movsb" : : "D"(__dst), "S"(__src), "c"(__n)); //FAIL</div><div style="font-size:13px">}</div><div style="font-size:13px"><br></div><div style="font-size:13px">int main(int argc, const char ** argv)</div><div style="font-size:13px">{</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>unsigned char dst[4]={'a', 'b', 'c', '\0'};</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>unsigned char src[4]={'1', '2', '3', '\0'};</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>__movsb_buggy(dst, src, 1);</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>puts((char*)dst); //expect "1bc", but get "bc"</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>puts((char*)src); //expect "123", but get "23"</div><div style="font-size:13px"><span class="gmail-m_-6101188913387601143gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>return 0;</div><div style="font-size:13px">}</div><div style="font-size:13px">------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------</div><div><br></div>
</div>