libstdc++/5424: std::ifstream::operator>>(int&) fails with negative hex numbers
paolo@gcc.gnu.org
paolo@gcc.gnu.org
Sat Jan 19 14:10:00 GMT 2002
Synopsis: std::ifstream::operator>>(int&) fails with negative hex numbers
State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Sat Jan 19 14:10:28 2002
State-Changed-Why:
In fact, the behaviour of libstdc++-v3 is strictly standard
conforming. Indeed, according to 22.2.2.2.2, Table 57, the
stdio equivalent of the conversion is %x, thus leading to
ffffffd6 for -42 (i.e., equivalent to printf("%x", -42)).
When the read is attempted it does *not* fit in a signed
int i, and it fails. You can fix your code by using an
unsigned int i.
Cheers,
Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5424
More information about the Gcc-prs
mailing list