This is the mail archive of the gcc-prs@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]
Other format: [Raw text]

c/7139: c long long error


>Number:         7139
>Category:       c
>Synopsis:       Shifting 1 through a 64bit int fails at 32bit line
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 26 23:36:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Simon Shapiro
>Release:        3.1
>Organization:
<Nomis Storage, Inc.>
>Environment:
System: NetBSD demodev.simon-shapiro.org 1.6_BETA1 NetBSD 1.6_BETA1 (GENERIC) #0: Thu May 30 14:19:08 CEST 2002 tron@lyssa.zhadum.de:/src/NetBSD-1.6/src/sys/arch/i386/compile/GENERIC i386


	
host: i386-Nomis-netbsdelf1.6.
build: i386-Nomis-netbsdelf1.6.
target: i386-Nomis-netbsdelf1.6.
configured with: /usr/local/src/gcc/gcc-3.1/configure --program-suffix=-3.1 --enable-version-specific-runtime-libs --disable-nls --with-local-prefix=/usr/pkg : (reconfigured) /usr/local/src/gcc/gcc-3.1/configure --program-suffix=-3.1 --enable-version-specific-runtime-libs --disable-nls
>Description:
	Run the program attached.  It says it all.  Tried on 2.7.2.3, 2.95, 3.0.4, 3.1 with identically wrong results.
>How-To-Repeat:
/*
 * Compile any which way, and run.
 * You will see the problem twice (at 32, 64)
 */

#include <stdio.h>

typedef union foo {
	unsigned long a[2];
	unsigned long long y;
	signed long long z;
} __attribute__((packed)) yuck_t;

int main()
{
	yuck_t yuck, fooie;
	int    i;

	fooie.y = yuck.y = 0;

	for (i = 0; i < 64; i++) {
		yuck.y |= 1 << i;
		fooie.y = 1 << i;

		(void)fprintf(stdout,
		  	"yuck(%d):  y = %qx, a[0] = %lx, a[1] = %lx\n",
		  	i, yuck.y, yuck.a[0], yuck.a[1]);
		(void)fprintf(stdout,
		  	"fooie(%d):  y = %qx, a[0] = %lx, a[1] = %lx\n",
		  	i, fooie.y, fooie.a[0], fooie.a[1]);
	}

	return(0);
}

>Fix:
	<You tell me :-)>

>Release-Note:
>Audit-Trail:
>Unformatted:


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