Boost logo

Boost :

Subject: [boost] Crazy Borland/Codegear long long behaviour?
From: John Maddock (john_at_[hidden])
Date: 2009-11-29 08:54:47


I'm having a load of trouble getting Boost.Integer to play nice with the
Borland/Codegear compilers, for example given:

void print_val(long long l)
{
   std::cout << std::hex << static_cast<int>((l & 0xFFFFFFFF00000000LL) >>
32);
   std::cout << std::hex << static_cast<int>((l & 0xFFFFFFFFLL)) <<
std::endl;
}

And then:

   static const long long MaxValue = SCHAR_MAX;
   static const long long sll = _LLONG_MAX;
   const long long cll = _LLONG_MAX;
   long long ll = _LLONG_MAX;
   BOOST_TEST(MaxValue <=
::boost::integer_traits<boost::long_long_type>::const_max); // fails
   BOOST_TEST(MaxValue <= _LLONG_MAX); // passes
   BOOST_TEST(MaxValue <= sll); //fails
   BOOST_TEST(MaxValue <= cll); // fails
   BOOST_TEST(MaxValue <= ll); // passes
   print_val(_LLONG_MAX); // OK prints 7fffffffffffffff
   print_val(ll); // OK prints 7fffffffffffffff
   print_val(sll); // Oh no, prints ffffffffffffffff
   print_val(cll); // Oh no, prints ffffffffffffffff

So as soon as a long long is declared const (whether static or not) it seems
to be incapable of actually holding a sensible value!!

Anyone got any ideas what's going on or any workarounds?

Thanks, John.

PS I'm still using Borland-5.8.2, but judging by the test matrix results the
latest versions have similar issues.


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