https://bugs.kde.org/show_bug.cgi?id=432801
--- Comment #9 from Eyal <eyals...@gmail.com> --- Oops, I spoke to soon. It's a bug in clang. Here's code that you can try: #include <signal.h> #include <string.h> #include <stdio.h> #include <stdlib.h> void foo() { // Put the garbage number 123 into eax. // It's caller-saved so no problem. __asm__ ("lea 123, %eax;"); // xmm variables are all caller-saved, too. // Fill them with garbage. __asm__ ("movd %eax, %xmm0"); __asm__ ("punpcklbw %xmm0, %xmm0"); __asm__ ("punpcklbw %xmm0, %xmm0"); __asm__ ("punpcklbw %xmm0, %xmm0"); __asm__ ("punpcklbw %xmm0, %xmm0"); __asm__ ("movd %eax, %xmm1"); __asm__ ("punpcklbw %xmm1, %xmm1"); __asm__ ("punpcklbw %xmm1, %xmm1"); __asm__ ("punpcklbw %xmm1, %xmm1"); __asm__ ("punpcklbw %xmm1, %xmm1"); __asm__ ("movd %eax, %xmm2"); __asm__ ("punpcklbw %xmm2, %xmm2"); __asm__ ("punpcklbw %xmm2, %xmm2"); __asm__ ("punpcklbw %xmm2, %xmm2"); __asm__ ("punpcklbw %xmm2, %xmm2"); __asm__ ("movd %eax, %xmm3"); __asm__ ("punpcklbw %xmm3, %xmm3"); __asm__ ("punpcklbw %xmm3, %xmm3"); __asm__ ("punpcklbw %xmm3, %xmm3"); __asm__ ("punpcklbw %xmm3, %xmm3"); __asm__ ("movd %eax, %xmm4"); __asm__ ("punpcklbw %xmm4, %xmm4"); __asm__ ("punpcklbw %xmm4, %xmm4"); __asm__ ("punpcklbw %xmm4, %xmm4"); __asm__ ("punpcklbw %xmm4, %xmm4"); } int main() { char pattern[] = "0123456789"; pattern[9] = 0; const unsigned long plen = strlen(pattern); foo(); size_t hp=0; for (size_t i = 0; i < plen; ++i) hp += pattern[i]; volatile int j = 0; if (hp==j) { j++; } printf("%ld\n", hp); return 1; } Run this with and without foo commented and see that the results are different. No valgrind need. Testing on godbolt, I see that the bug is present even through clang 11.0.1 https://godbolt.org/z/6s1rTd -- You are receiving this mail because: You are watching all bug changes.