Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2005-04-20 03:06:00


The following is a repost of a message I mailed in last september. The
problem with the test is still present in the current CVS. Would anyone
mind if I just go for the first fix proposed?

Markus

---%<---
Currently the integer tests report an error on 64 bit platforms, as can be
seen on http://tinyurl.com/7aoe9

The following code in integer_test.cpp causes the problem:

     PRIVATE_FIT_TESTS( int_t, least, long, LONG_MAX );
     PRIVATE_FIT_TESTS( int_t, fast, long, LONG_MAX );
     PRIVATE_FIT_TESTS( uint_t, least, unsigned long, ULONG_MAX );
     PRIVATE_FIT_TESTS( uint_t, fast, unsigned long, ULONG_MAX );

The first line expands to:

do {
   long v = LONG_MAX ;
   PRIVATE_FIT_TEST(int_t, 32, least, v);
   v >>= 1;
   PRIVATE_FIT_TEST(int_t, 31, least, v);
   v >>= 1;
   ...
}

which becomes:

do {
   long v = LONG_MAX ;
   BOOST_TEST( int_t < 32 > :: least ( v ) == v );
   v >>= 1;
   BOOST_TEST( int_t < 31 > :: least ( v ) == v );
   v >>= 1;
   ...
}

which of course alway fails on 64 bit platforms because LONG_MAX is a 64
bit number.

A possible fix would be to start the test with 64 bit and not 32 on 64 bit
platforms. But how can 64 bit platforms be detected? Probably with #if
(LONG_MAX > INT_MAX) ... #endif or something like this.

Another fix (which ignores 64 bit values alltogether) would be to change
the lines above to not use long and LONG_MAX but int and INT_MAX.

Opinions, anyone?

Markus
--->%---


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk