-O2 bug in gcc 3.2, 3.3 and 3.4 with 64 bit integers on x86
Anders Torger
torger@ludd.luth.se
Tue Nov 9 16:15:00 GMT 2004
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.
More information about the Gcc-bugs
mailing list