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

Jan van Dijk jan at etpmod.phys.tue.nl
Wed Nov 1 05:45:21 PST 2006


	Hello,

On my 64 bit Linux system (with gcc-4.1.0) hashmap.h generates (serious) 
compiler warnings when compiling wx-head:

../include/wx/hashmap.h: In member function ‘size_t 
wxIntegerHash::longlongHash(long long int) const’:
../include/wx/hashmap.h:471: warning: right shift count >= width of type

From inspection of the code, this is caused by a deeper problem, the fact that 
wxLongLongIsLong is *not* defined, although on my system 
sizeof(long)==sizeof(long long)==8.

The problem is probably the logic in include/wx/defs.h, around line 912 that 
reads:

[...]
/*  first check for compilers which have the real long long */
#if (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8)  || \
[...]

On my system this evaluates as true, while wxIsLongLong is defined only in the 
last #else block.

Shouldn't the ">=8" check be replaced with ">SIZEOF_LONG"? Similar reasoning 
applies to the "== 8" check on line 955 in the same file.

On a side note, wouldn't it in addition be much more readable to define 
wxIsLongLong in a separate macro block, smth. like:

#if (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == SIZEOF_LONG)
#define wxLongLongIsLong
#endif

From inspection of the code this (serious) problem should be present in 2.7.2 
as well...

Thank you for your time,

	Jan van Dijk.

-- 
If I haven't seen further, it is by standing in the footprints of giants




More information about the wx-dev mailing list