From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7652 invoked by alias); 18 May 2009 19:35:46 -0000 Received: (qmail 7630 invoked by uid 48); 18 May 2009 19:35:35 -0000 Date: Mon, 18 May 2009 19:35:00 -0000 Subject: [Bug c/40189] New: gcc 4.4.0 incorrectly folds add-as-comparison X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mat at lcs dot mit dot edu" 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: 2009-05/txt/msg01564.txt.bz2 This code: int foo(int arg0) { if ((-2147483647 - 1) + arg0) return 20; else return 11; } when compiled with gcc-4.4.0 at -O2 or higher, simply returns 20 unconditionally: $ ~/x86-gcc4/bin/gcc -m32 -O2 -S ~/baz.c -o /dev/tty .file "baz.c" .text .p2align 4,,15 .globl foo .type foo, @function foo: pushl %ebp movl $20, %eax movl %esp, %ebp popl %ebp ret .size foo, .-foo .ident "GCC: (GNU) 4.4.0" .section .note.GNU-stack,"",@progbits This bug appears to be architecture-independent (I've seen it on x86, x86_64, and another chip). The bug did not happen in gcc-4.0.2. Here is some information about my system: $ ~/x86-gcc4/bin/gcc --version gcc (GCC) 4.4.0 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ uname -a Linux ld-1 2.6.9-42.0.8.ELsmp #1 SMP Tue Jan 30 12:18:01 EST 2007 x86_64 x86_64 x86_64 GNU/Linux $ file bin/gcc bin/gcc: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped -- Summary: gcc 4.4.0 incorrectly folds add-as-comparison Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mat at lcs dot mit dot edu GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40189