
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Dean Michael Berris Sent: 07 May 2007 12:14 To: boost@lists.boost.org Subject: [boost] [HEAD] lexical_cast<int8_t>("127") bug?
Hi Everyone,
I've recently tried the following (inlined test) which isolates the problem I've encountered with boost::lexical_cast<int8_t>:
#include <iostream> #include <boost/lexical_cast.hpp>
int main(int argc, char * argv[]) { int8_t value; try { value = boost::lexical_cast<int8_t>("127"); } catch (std::exception & e) { std::cerr << e.what() << '\n'; } return 0; };
This is compiled with gcc 4.1.2 on Linux. Any idea why 127 wouldn't fit into an 8-bit signed integer? The defined range for signed 8 bit integers should be -127..+127 right?
I also recollect that I never understood why zz = lexical_cast<int>("0xffff"); // Fails! However I was more concerned about the floating-point problems, now sorted out, and I didn't waste any brain activity on it. (This was with MSVC 7 and 8). Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com