From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14187 invoked by alias); 18 Jan 2002 21:51:03 -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 14156 invoked by uid 61); 18 Jan 2002 21:51:00 -0000 Date: Fri, 18 Jan 2002 13:51:00 -0000 Message-ID: <20020118215100.14155.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/msg00674.txt.bz2 List-Id: Synopsis: std::ifstream::operator>>(int&) fails with negative hex numbers State-Changed-From-To: feedback->analyzed State-Changed-By: paolo State-Changed-When: Fri Jan 18 13:51:00 2002 State-Changed-Why: The testcase: #include #include bool stream_in( void ) { std::ifstream is( "foo.txt" ); is.setf( std::ios::hex, std::ios::basefield ); int i=0; if ( !(is.good() && is.is_open()) ) return false; is >> i; if ( !is ) return false; if ( is.peek() == '\n' ) is.ignore(); if ( !is ) return false; is >> i; if ( !is ) return false; if ( is.peek() == '\n' ) is.ignore(); if ( !is ) return false; return true; } bool stream_out( void ) { std::ofstream os( "foo.txt" ); os.setf( std::ios::hex, std::ios::basefield ); if ( !(os.good() && os.is_open()) ) return false; os << -42 << '\n' << 42 << '\n'; return true; } int main( int argc, char*argv[] ) { if ( !stream_out() ) std::cerr << "std::ostream failed" << std::endl; else if ( !stream_in() ) std::cerr << "std::istream failed" << std::endl; return 0; } http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5424