This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: -O2 bug in gcc 3.2, 3.3 and 3.4 with 64 bit integers on x86
Compiler makes same mistake, the only difference is the warning at
compile time, which can be avoided with this casting trick:
return ((unsigned long *)(void *)&ull)[0] ^
((unsigned long *)(void *)&ull)[1];
/Anders
On Tuesday 09 November 2004 16.56, you wrote:
> Anders Torger <torger@ludd.luth.se> writes:
> > unsigned long
> > hash(void *key)
> > {
> > unsigned long long ull;
> > ull = *(unsigned long long *)key;
> > return ((unsigned long *)&ull)[0] ^ ((unsigned long *)&ull)[1];
>
> Try -Wstrict-aliasing.
>
> Andreas.