From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3771 invoked by alias); 19 Feb 2011 00:23:23 -0000 Received: (qmail 3761 invoked by uid 22791); 19 Feb 2011 00:23:22 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_DD X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Feb 2011 00:23:18 +0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/47812] New: [x32] __builtin_strlen is miscompiled at -O2 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sat, 19 Feb 2011 00:56:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg02222.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: hjl.tools@gmail.com CC: ubizjak@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.