[Boost.Integer] On Win32, boost::uint_t<65>::fast has 64 bits?
The type yielded by boost::uint_t<N>::fast seems pretty clear: "The
easiest-to-manipulate, built-in, unsigned integral type with at least N
bits."
But when I run the following program, which prints the number of bits in
the type returned by boost::uint_t<65>::fast (i.e., a type with at least
65 bits), I get 64.
#include <iostream>
#include <climits>
#include
AMDG On 05/01/2012 05:25 PM, Scott Meyers wrote:
The type yielded by boost::uint_t<N>::fast seems pretty clear: "The easiest-to-manipulate, built-in, unsigned integral type with at least N bits."
But when I run the following program, which prints the number of bits in the type returned by boost::uint_t<65>::fast (i.e., a type with at least 65 bits), I get 64.
#include <iostream> #include <climits> #include
int main() { std::cout << "boost::uint_t<65>::fast has " << CHAR_BIT * sizeof(boost::uint_t<65>::fast) << " bits\n"; }
I get the same results with VC10, VC11 beta, and gcc 4.7 on Win32 with Boost 1.49. I must be doing something wrong, right? But what?
Obviously this isn't going to work unless the compiler supports a 128-bit int. I suppose it would be better to cause a compile error if there isn't a sufficiently wide integer type. In Christ, Steven Watanabe
On 5/1/2012 10:40 PM, Steven Watanabe wrote:
Obviously this isn't going to work unless the compiler supports a 128-bit int. I suppose it would be better to cause a compile error if there isn't a sufficiently wide integer type.
That's what it's documented to do. Here's the full spec for boost::uint_t<N>::fast :
The easiest-to-manipulate, built-in, unsigned integral type with at least N bits. The parameter should be a positive number. A compile-time error results if the parameter is larger than the number of bits in the largest integer type.
If I change 65 to 66, the code fails to compile. Can something this simple really be a bug in the library? Yes, I know, I could check the source code, but I'm being lazy right now. If this is not a clear case of pilot error, I'll take a look. Thanks, Scott
The easiest-to-manipulate, built-in, unsigned integral type with at least N bits. The parameter should be a positive number. A compile-time error results if the parameter is larger than the number of bits in the largest integer type.
If I change 65 to 66, the code fails to compile. Can something this simple really be a bug in the library? Yes, I know, I could check the source code, but I'm being lazy right now. If this is not a clear case of pilot error, I'll take a look.
Confirmed as a bug, and fixed in Trunk - can't really see how it was ever expected to work really :-( Thanks for the heads-up, John.
Le 02/05/12 19:11, John Maddock a écrit :
The easiest-to-manipulate, built-in, unsigned integral type with at least N bits. The parameter should be a positive number. A compile-time error results if the parameter is larger than the number of bits in the largest integer type.
If I change 65 to 66, the code fails to compile. Can something this simple really be a bug in the library? Yes, I know, I could check the source code, but I'm being lazy right now. If this is not a clear case of pilot error, I'll take a look.
Confirmed as a bug, and fixed in Trunk - can't really see how it was ever expected to work really :-(
Hi, this was reported already here http://boost.2283326.n4.nabble.com/integer-Bug-in-int-t-lt-65-gt-tt4415449.h... Was the patch I proposed be applied? if yes, what is wrong now? Best, Vicente
----- Original Message -----
From: "Vicente J. Botet Escriba"
The easiest-to-manipulate, built-in, unsigned integral type with at least N bits. The parameter should be a positive number. A compile-time error results if the parameter is larger than the number of bits in the largest integer type.
If I change 65 to 66, the code fails to compile. Can something this simple really be a bug in the library? Yes, I know, I could check the source code, but I'm being lazy right now. If this is not a clear case of pilot error, I'll take a look.
Confirmed as a bug, and fixed in Trunk - can't really see how it was ever expected to work really :-(
this was reported already here http://boost.2283326.n4.nabble.com/integer-Bug-in-int-t-lt-65-gt-tt4415449.h...
Was the patch I proposed be applied? if yes, what is wrong now?
That was applied and is in 1.49, but a different issue effects uint_t specifically. John.
The type yielded by boost::uint_t<N>::fast seems pretty clear: "The easiest-to-manipulate, built-in, unsigned integral type with at least N bits."
But when I run the following program, which prints the number of bits in the type returned by boost::uint_t<65>::fast (i.e., a type with at least 65 bits), I get 64.
#include <iostream> #include <climits> #include
int main() { std::cout << "boost::uint_t<65>::fast has " << CHAR_BIT * sizeof(boost::uint_t<65>::fast) << " bits\n"; }
I get the same results with VC10, VC11 beta, and gcc 4.7 on Win32 with Boost 1.49. I must be doing something wrong, right? But what?
I seem to remember fixing that as a bug fairly recently - what Boost version are you using? John.
Hi john,
On Wed, May 2, 2012 at 3:21 PM, John Maddock
I get the same results with VC10, VC11 beta, and gcc 4.7 on Win32 with Boost 1.49. I must be doing something wrong, right? But what?
I seem to remember fixing that as a bug fairly recently - what Boost version are you using?
Its one line above your reply, seems to be 1.49. Best, Dee
On Wed, May 2, 2012 at 3:21 PM, John Maddock
wrote: I get the same results with VC10, VC11 beta, and gcc 4.7 on Win32 with Boost 1.49. I must be doing something wrong, right? But what?
I seem to remember fixing that as a bug fairly recently - what Boost version are you using?
Its one line above your reply, seems to be 1.49.
Doh!! The problem is still there in SVN Trunk as well... John.
On 5/2/2012 1:32 AM, John Maddock wrote:
The problem is still there in SVN Trunk as well...
Okay, so apparently not pilot error. Good to know, thanks. FWIW, the coding error appears to be different in uint_t<N> and int_t<N>, though I have not looked at the source code. In particular, int_t<66> won't compile (int_t<65> will), while uint_t<66> will. So uint_t is accepting some invalid values that int_t is rejecting though, as I said, both accept the invalid value (for my machine) of 65. When int_t<66> is rejected, VC11 says this:
C:\Users\Scott\Libraries\Boost\Current\boost/integer.hpp(125): error C2039: 'least': is not a member of 'boost::detail::int_least_he lper<Category>' with [ Category=0 ] uinttest.cpp(9): see reference to class template instantiation 'boost::int_t<Bits>' being compiled with [ Bits=66 ] C:\Users\Scott\Libraries\Boost\Current\boost/integer.hpp(125): error C2146: syntax error : missing ';' before identifier 'least' C:\Users\Scott\Libraries\Boost\Current\boost/integer.hpp(125): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Users\Scott\Libraries\Boost\Current\boost/integer.hpp(125): error C2602: 'boost::int_t<Bits>::least' is not a member of a base cl ass of 'boost::int_t<Bits>' with [ Bits=66 ] C:\Users\Scott\Libraries\Boost\Current\boost/integer.hpp(125): see declaration of 'boost::int_t<Bits>::least' with [ Bits=66 ] C:\Users\Scott\Libraries\Boost\Current\boost/integer.hpp(125): error C2868: 'boost::int_t<Bits>::least': illegal syntax for using-de claration; expected qualified-name with [ Bits=66 ]
gcc 4.7 says:
C:\Users\Scott\Libraries\Boost\Current/boost/integer.hpp: In instantiation of 'boost::int_t<66>': uinttest.cpp:9:50: required from here C:\Users\Scott\Libraries\Boost\Current/boost/integer.hpp:125:19: error: no type named 'least' in 'boost::detail::int_least_helper<0>' C:\Users\Scott\Libraries\Boost\Current/boost/integer.hpp:126:49: error: no type named 'least' in 'boost::detail::int_least_helper<0>'
Neither message is very helpful. Would it be possible to add use of static_assert, at least in C++11 code? Thanks, Scott
participants (5)
-
Diederick C. Niehorster
-
John Maddock
-
Scott Meyers
-
Steven Watanabe
-
Vicente J. Botet Escriba