From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7577 invoked by alias); 19 Jan 2002 22:10:28 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 7545 invoked by uid 61); 19 Jan 2002 22:10:28 -0000 Date: Sat, 19 Jan 2002 14:10:00 -0000 Message-ID: <20020119221028.7544.qmail@sources.redhat.com> To: doerntge@kiwilogic.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org From: paolo@gcc.gnu.org Reply-To: paolo@gcc.gnu.org, doerntge@kiwilogic.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org X-Mailer: gnatsweb 2.9.3 Subject: Re: libstdc++/5424: std::ifstream::operator>>(int&) fails with negative hex numbers X-SW-Source: 2002-01/txt/msg00693.txt.bz2 List-Id: 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