|
Boost : |
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2007-05-07 08:13:33
Dean Michael Berris wrote:
> 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?
>
-128..+127 in 2's complement, actually.
Can confirm for 1.33.1 with GCC 4.1.1. Seems to be a bug.
Sebastian Redl
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk