From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24293 invoked by alias); 21 Dec 2001 13:26:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 24226 invoked by uid 71); 21 Dec 2001 13:26:01 -0000 Resent-Date: 21 Dec 2001 13:26:01 -0000 Resent-Message-ID: <20011221132601.24225.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, Richard.Earnshaw@arm.com Resent-Reply-To: gcc-gnats@gcc.gnu.org, Klaus.k.pedersen@nokia.com Received:(qmail 22346 invoked by uid 61); 21 Dec 2001 13:19:37 -0000 Message-Id:<20011221131937.22345.qmail@sources.redhat.com> Date: Fri, 21 Dec 2001 05:26:00 -0000 From: Klaus.k.pedersen@nokia.com Reply-To: Klaus.k.pedersen@nokia.com To: gcc-gnats@gcc.gnu.org Cc: Richard.Earnshaw@arm.com X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify:Richard.Earnshaw@arm.com Subject: target/5169: Bug in pa-risc gcc optimizer X-SW-Source: 2001-12/txt/msg01034.txt.bz2 List-Id: >Number: 5169 >Category: target >Synopsis: Bug in pa-risc gcc optimizer >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri Dec 21 05:26:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Klaus Pedersen >Release: all - at least from 2.95 and up >Organization: >Environment: HP-UX 11, HP-UX 10.20, gcc 2.95.2, to current snapshot For example gcc -v Reading specs from /opt/net/local/gcc302/lib/gcc-lib/hppa1.1-hp-hpux11.00/3.0.2/specs Configured with: ../configure --enable-haifa --with-gnu-as --with-included-gettext --enable-shared --enable-languages=c,c++,f77 --enable-threads=posix --prefix=/opt/net/local/gcc302 --with-local-prefix=/opt/net/local/gcc302 Thread model: posix gcc version 3.0.2 I have tried a wide selection of HP boxes (thanks to rodrigc@gcc.gnu.org, who claims that he doesn't have any problems on HP). - from personal workstations: HP-UX coicxxx B.11.00 A 9000/785 2014470784 two-user license to N-class servers: HP-UX caswxxx B.11.00 U 9000/800 600309332 unlimited-user license >Description: See also bootstrap/3479, closed by rodrigc@gcc.gnu.org See also target/5107, investigated by Richard.Earnshaw@arm.com The attached program, which is the reason that it is impossible to build a cross compiler for ARM on HP-UX with default CFLAGS=-O2. Here is the program in all its glory: ---- int main() { int operands[10] = {0, 65536}; unsigned int val = operands[1]; unsigned int mask = 0xff; int i; for (i = 0; i < 25; i++) if ((val & (mask << i)) == val) break; if (i == 0) puts("Fail"); return 0; } ---- The problem seem to be that "if (i==0)" is always true! >How-To-Repeat: Compile and run attached program: gcc -O1 hp-bug-1.c ./a.out Everything is OK. When compiling with -O2: gcc -O2 hp-bug-1.c ./a.out the program returns "fail". >Fix: Never compile with higher optimizer settings than -O1 :-( >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/x-unknown-content-type-c_auto_file; name="hp-bug-1.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="hp-bug-1.c" aW50IG1haW4oKQp7CiAgICBpbnQgb3BlcmFuZHNbMTBdID0gezAsIDY1NTM2fTsKICAgIHVuc2ln bmVkIGludCB2YWwgPSBvcGVyYW5kc1sxXTsKICAgIHVuc2lnbmVkIGludCBtYXNrID0gMHhmZjsK ICAgIGludCBpOwogICAgCiAgICBmb3IgKGkgPSAwOyBpIDwgMjU7IGkrKykKICAgICAgaWYgKCh2 YWwgJiAobWFzayA8PCBpKSkgPT0gdmFsKQogICAgICAgIGJyZWFrOwoKICAgIGlmIChpID09IDAp CiAgICAgIHB1dHMoIkZhaWwiKTsKCiAgICByZXR1cm4gMDsKfQo=