[wx-dev] (64 bit) hashmap/long long problem in HEAD and 2.7.2

Vadim Zeitlin vadim at wxwindows.org
Wed Nov 1 06:07:36 PST 2006


On Wed, 1 Nov 2006 14:45:21 +0100 Jan van Dijk <jan at etpmod.phys.tue.nl> wrote:

JvD> On my 64 bit Linux system (with gcc-4.1.0) hashmap.h generates (serious) 
JvD> compiler warnings when compiling wx-head:
JvD> 
JvD> ../include/wx/hashmap.h: In member function ‘size_t 
JvD> wxIntegerHash::longlongHash(long long int) const’:
JvD> ../include/wx/hashmap.h:471: warning: right shift count >= width of type
JvD> 
JvD> From inspection of the code, this is caused by a deeper problem, the fact that 
JvD> wxLongLongIsLong is not defined, although on my system 
JvD> sizeof(long)==sizeof(long long)==8.

 I think it's correct that wxLongLongIsLong is not defined. This symbol is
used, at least according to the comments before its definition, to avoid
defining overloaded functions for long and wxLongLong_t parameters which
doesn't work when wxLongLong_t is the same as long as it results in
duplicate declaration. However if wxLongLong_t is "long long", then it's a
separate type from long just as long is separate type from int even if both
of them have the same size.

JvD> The problem is probably the logic in include/wx/defs.h, around line 912 that 
JvD> reads:
JvD> 
JvD> [...]
JvD> /*  first check for compilers which have the real long long */
JvD> #if (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8)  || \
JvD> [...]
JvD> 
JvD> On my system this evaluates as true, while wxIsLongLong is defined only in the 
JvD> last #else block.

 So I do not think this is a problem.

 The problem is shift by sizeof(long) bytes in wx/hashmap.h, we really need
to shift by sizeof(long long)/2 here. I am not sure what's the best way to
fix it though -- sizeof(size_t) is 4 on 64 bit Unix machines usually, but
it is 8 under Windows. So I guess it's better to use wxUint32 explicitly
here even though it's still wrong for sizeof(size_t) == 8.

 Anyhow, please let me know if you still have any problems with the
revision 1.61 of wx/hashmap.h.
 
 Thanks,
VZ





More information about the wx-dev mailing list