This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/5424: std::ifstream::operator>>(int&) fails with negative hex numbers
- From: paolo at gcc dot gnu dot org
- To: doerntge at kiwilogic dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 19 Jan 2002 22:10:28 -0000
- Subject: Re: libstdc++/5424: std::ifstream::operator>>(int&) fails with negative hex numbers
- Reply-to: paolo at gcc dot gnu dot org, doerntge at kiwilogic dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
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