From owner-freebsd-bugs Wed Sep 20 16: 0:11 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2B12137B423 for ; Wed, 20 Sep 2000 16:00:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id QAA60388; Wed, 20 Sep 2000 16:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 1F12637B423; Wed, 20 Sep 2000 15:50:36 -0700 (PDT) Message-Id: <20000920225036.1F12637B423@hub.freebsd.org> Date: Wed, 20 Sep 2000 15:50:36 -0700 (PDT) From: earl_chew@agilent.com To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: gnu/21433: g++ optimiser produces bad code on right shift of 64 bit integer Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 21433 >Category: gnu >Synopsis: g++ optimiser produces bad code on right shift of 64 bit integer >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Sep 20 16:00:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Earl Chew >Release: 4.0-RELEASE >Organization: Agilent Technologies >Environment: FreeBSD bna2188.canada.agilent.com 4.0-RELEASE FreeBSD 4.0-RELEASE #0: Mon Mar 2 0 22:50:22 GMT 2000 root@monster.cdrom.com:/usr/src/sys/compile/GENERIC i38 6 >Description: The attached test harness fragment dealing with >> on 64 bit integers fails when optimisation is enabled. The program works when no optimisation is used. Compile with g++ -O foo.cc. Running the program yields: 0x8888222233334444 0 0x8888222233334444 0xffffffff33334444 Failed: Signed negative right shift identity operation >How-To-Repeat: #include typedef unsigned long long AtoUInt64T; typedef long long AtoInt64T; typedef AtoUInt64T U; typedef AtoInt64T S; int main() { do { S r ((AtoUInt64T) ( 0x88882222UL ) << 32 | (AtoUInt64T) ( 0x33334444UL )) ; S a ((AtoUInt64T) ( 0x88882222UL ) << 32 | (AtoUInt64T) ( 0x33334444UL )) ; int b = 0x0+0x00 ; S c; c = a >> b; if (c != r) { printf("0x%llx %d\n", a, b); printf("0x%llx 0x%llx\n", r, c); printf("Failed: %s\n", "Signed negative right shift identity operation" ); abort(); } } while (0) ; return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message