dereferencing type-punned pointer warning
Hi, line 135 in lout object.cc: return ((int*)&value)[0] ^ ((int*)&value)[1]; causes the following error on 64bit systems for me: warning: dereferencing type-punned pointer will break strict-aliasing rules Can we replace it like this: diff -r dd6f2d1eb15a lout/object.cc --- a/lout/object.cc Mon Jan 14 10:26:37 2013 -0300 +++ b/lout/object.cc Mon Jan 14 21:56:46 2013 +0100 @@ -21,6 +21,7 @@ #include "object.hh" #include <stdio.h> +#include <stdint.h> #include <config.h> namespace lout { @@ -132,7 +133,7 @@ // Combine both parts of the pointer value *itself*, not what it // points to, by first referencing it (operator "&"), then // dereferencing it again (operator "[]"). - return ((int*)&value)[0] ^ ((int*)&value)[1]; + return ((intptr_t)value >> 32) ^ ((intptr_t)value); #endif } Cheers, Johannes
On Mon, Jan 14, Johannes Hofmann wrote:
line 135 in lout object.cc: return ((int*)&value)[0] ^ ((int*)&value)[1];
causes the following error on 64bit systems for me:
warning: dereferencing type-punned pointer will break strict-aliasing rules
Can we replace it like this: [...]
Committed, and tested with an amd64 system. Actually, this code is never used in dillo, but in objman-test, for which I fixed a bug in this method. Sebastian
participants (2)
-
Johannes.Hofmann@gmx.de
-
sgeerken@dillo.org