This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/8758: gcc 3.2.1 gives bad values to a long longvariable when optimizing with O2
- From: Andreas Jaeger <aj at suse dot de>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 29 Nov 2002 17:26:01 -0000
- Subject: Re: optimization/8758: gcc 3.2.1 gives bad values to a long longvariable when optimizing with O2
- Reply-to: Andreas Jaeger <aj at suse dot de>
The following reply was made to PR optimization/8758; it has been noted by GNATS.
From: Andreas Jaeger <aj@suse.de>
To: bhelmste@ai.univ-paris8.fr
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/8758: gcc 3.2.1 gives bad values to a long long
variable when optimizing with O2
Date: Fri, 29 Nov 2002 18:21:53 +0100
GCC 3.3 reports on your code:
gromit:/tmp:[29]$ /opt/gcc/3.3-devel/bin/gcc -O2 -Wall ~/bug.c
/home/aj/bug.c: In function `main':
/home/aj/bug.c:16: warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/aj/bug.c:17: warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/aj/bug.c:18: warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/aj/bug.c:19: warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/aj/bug.c:21: warning: integer constant is too large for "long" type
/home/aj/bug.c:23: warning: integer constant is too large for "long" type
gromit:/tmp:[0]$ ./a.out
hashval should be 0,
but hashval = 1122334455667788
and hashval = 11223344080495ac
gromit:/tmp:[0]$ /opt/gcc/3.3-devel/bin/gcc -O2 -Wall ~/bug.c -fno-strict-aliasing
/home/aj/bug.c: In function `main':
/home/aj/bug.c:21: warning: integer constant is too large for "long" type
/home/aj/bug.c:23: warning: integer constant is too large for "long" type
gromit:/tmp:[0]$ ./a.out
Your code is violating the strict aliasing rules (note the warnings
are correct here!) and therefore broken. Please fix your code or
compile with -fno-strict-aliasing,
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj