Opened 19 years ago

Closed 17 years ago

#200 closed Bugs (Wont Fix)

cast.hpp: greater_than_type_max<false, false> int/uint

Reported by: nobody Owned by: david_abrahams
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

Submitted by holger.joukl@lbbw.de
File boost/boost/boost/cast.hpp:
If the greater_than_type_max check method is called in
this specialization:
  greater_than_type_max<false, false>.check(x, y)
with 
  unsigned int x 
and
  int y=INT_MAX,
and x is bigger than INT_MAX, the check fails.

Maybe it could be done this way (but I am C++ newbie,
so I might
overlook the subtleties):

 *** cast.hpp.orig       Wed Sep 17 11:45:33 2003
--- cast.hpp    Wed Sep 17 11:47:12 2003
***************
*** 295,301 ****
          // will work with every compiler I know of.
          template <class X, class Y>
          static inline bool check(X x, Y)
!             { return
static_cast<X>(static_cast<Y>(x)) != x; }
      };
 
  #else // use #pragma hacks if available
--- 295,301 ----
          // will work with every compiler I know of.
          template <class X, class Y>
          static inline bool check(X x, Y)
!             { return
(static_cast<X>(static_cast<Y>(x)) != x) ||
(static_cast<Y>(x) < 0); }
      };
 
  #else // use #pragma hacks if available

Change History (1)

comment:1 by david_abrahams, 17 years ago

Status: assignedclosed
Summary: cast.hpp: greater_than_type_max<false, false> int/uint bug cast.hpp: greater_than_type_max<false, false> int/uint
Logged In: YES 
user_id=52572

That fix doesn't look right to me, and this code has long
since been obsoleted and replaced by a better implementation
for all but a few broken out-of-date compilers.  I'm afraid
it's not worth trying to make it better.
Note: See TracTickets for help on using tickets.