This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GCC 2.95.2 for AIX handles 'long long' incorrectly




Attached is a simple testcase of a function that returns a 'long long'

GCC version 2.95.2 produced incorrect results when the optimizer is
enabled.

# this is a IBM 397 with 1G of memory
$ uname -a
AIX pdxcs566 1 4 000111179400
$ ./gcc -v                
Reading specs from /fs15/wmt.ntcsim.1/mafetter/gcc-2.95.2-rs6k-install/lib/gcc-lib/rs6000-ibm-aix4.1.5.0/2.95.2/specs
gcc version 2.95.2 19991024 (release)
$ ./gcc aix_uint64_bug.cc
$ ./a.out
400000000
good
$ ./gcc -O aix_uint64_bug.cc
$ ./a.out
400000000
bug

I can send any other info required to reproduce the bug.

This is cause bugs in our project.  Any suggested workarounds?

-Wayne

Wayne Scott		        MD6 Architecture - Intel Corp.
wscott@ichips.intel.com		Work #: (503) 613-5063
Disclaimer:  All views expressed are my own opinions, and not necessarily 
             those of Intel Corporation.


#include <stdio.h>

typedef unsigned long long uint64;
const uint64 bigconst = 1ULL << 34;

int a = 1;

static 
uint64 getmask(void)
{
	if (a)
		return bigconst;
	else
		return 0;
}

main()
{
	printf("%llx\n", bigconst);
	uint64 f = getmask();
	printf("%s\n", f ? "good" : "bug");
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]