Subject: bin/22313: gcc3 fails with -O2 and bswap64()
To: None <gnats-bugs@gnats.netbsd.org>
From: None <gcw@primenet.com.au>
List: netbsd-bugs
Date: 07/31/2003 12:28:00
>Number: 22313
>Category: bin
>Synopsis: gcc3 fails with -O2 and bswap64()
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 31 02:29:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Geoff C. Wing
>Release: NetBSD 1.6U
>Organization:
>Environment:
System: NetBSD g.primenet.com.au 1.6U NetBSD 1.6U (G) #0: Mon Jul 28 12:42:54 EST 2003 gcw@g.primenet.com.au:/usr/netbsd/src/sys/arch/i386/compile/G i386
Architecture: i386
Machine: i386
>Description:
gcc 3.3.1 20030720 (prerelease) fails in optimising mixed 32 & 64 bit
data types on i386
% fortune
!07/11 PDP a ni deppart m'I !pleH
% fortune
!07/11 PDP a ni deppart m'I !pleH
Seems to be caused by -fstrict-aliasing
Using -O1 and the other flags specified in the -O2 section of the
manual works.
>How-To-Repeat:
------------------------------------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <machine/bswap.h>
u_int64_t a_bswap64(u_int64_t); /* copy of bswap64() function */
main()
{
u_int64_t a;
u_int8_t *b = (u_int8_t *)(void *)&a;
int i;
a = bswap64(1);
printf("%lld\n", a);
for (i = 0; i < sizeof(a) / sizeof(u_int8_t); i++)
printf("%d:%d\n", i, b[i]);
}
u_int64_t
a_bswap64(x)
u_int64_t x;
{
u_int32_t *p = (u_int32_t*)(void *)&x;
u_int32_t t;
t = bswap32(p[0]);
p[0] = bswap32(p[1]);
p[1] = t;
return x;
}
------------------------------------------------------------
>Fix:
?
>Release-Note:
>Audit-Trail:
>Unformatted: