Date: Wed, 20 Sep 2000 15:50:36 -0700 (PDT) From: earl_chew@agilent.com To: freebsd-gnats-submit@FreeBSD.org Subject: gnu/21433: g++ optimiser produces bad code on right shift of 64 bit integer Message-ID: <20000920225036.1F12637B423@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <stdio.h>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000920225036.1F12637B423>
