This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/14174] New: bug and workaround for stringstream tellg and operator>>


There seems to be a bug in stringstream. Consider the following code segment.
It yields:

abc
xyz

But should yield:

abc
bc

The workaround is to add a white space to "abc", i.e.: s << "abc ".

Regards

Uwe Sassenberg
Science-D-Visions

--------------------------8<--------------------------
	std::stringstream s;
	std::string a;
	
	s << "abc";

// here it works
	s >> a;
	std::cout << a << std::endl;
	
// set get-position to character 'b' in "abc"
	s.seekg(1);

// put some other content into a
	a = "xyz";

// here it doesn't work
	s >> a;
	std::cout << a << std::endl;
--------------------------8<--------------------------

-- 
           Summary: bug and workaround for stringstream tellg and operator>>
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bugzilla dot 20 dot kuhfladen at spamgourmet dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14174


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]