libstdc++/5424: ifstream::operator>>(int&) malfunction

Rainer Doerntge doerntge@kiwilogic.com
Fri Jan 18 04:56:00 GMT 2002


>Number:         5424
>Category:       libstdc++
>Synopsis:       std::ifstream::operator>>(int&) fails with negative hex numbers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 18 04:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.0.3
>Organization:
Kiwilogic.com AG
>Environment:
System: Linux klservedv 2.4.9-13smp #1 SMP Tue Oct 30 19:57:16 EST 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --enable-exceptions --enable-threads
>Description:
	Any negative int written to a file with std::ofstream::operator<<(int
	const&) and std::ios::hex as basefield is written in the
	complementary notation (-1 becomes ffffffff). When
	std::ifstream::operator>>(int&) tries to read that number
	again, the failbit gets set. This work finely under g++ < v3,
	Sun Forte C++, Borland's BCB5 and others.

>How-To-Repeat:
	Write -1 to an ofstream in hex basefield mode and
	try to read it in again in hex basefield mode using
	std::ifstream
>Fix:
	Read the number as string and convert it afterwards using
	e. g. atoi.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list