http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47812
Summary: [x32] __builtin_strlen is miscompiled at -O2 Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: hjl.to...@gmail.com CC: ubiz...@gmail.com On x32 branch, I got [hjl@gnu-6 strcat-1]$ cat tester.c char one[50] = "ijk"; int main (void) { return __builtin_strlen (one) != 3; } [hjl@gnu-6 strcat-1]$ make tester.s /usr/gcc-4.6.0-x32/bin/gcc -mx32 -g -O2 -S tester.c -o tester.s [hjl@gnu-6 strcat-1]$ cat tester.s .file "tester.c" .text .Ltext0: .section .text.startup,"ax",@progbits .p2align 4,,15 .globl main .type main, @function main: .LFB0: .file 1 "tester.c" .loc 1 4 0 .cfi_startproc .loc 1 5 0 movl $one, %edx .L2: movl (%rdx), %eax addq $4, %rdx leal -16843009(%eax), %ecx notl %eax andl %eax, %ecx andl $-2139062144, %ecx je .L2 .loc 1 6 0 movl $1, %eax ret .cfi_endproc This always returns 1 instead of 0.