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++/32608] New: operator >> loads wrong value after istringsstream::str( string ).


$ cat iss.cpp
#include <iostream>
#include <sstream>
#include <cassert>

int main()
{
        std::istringstream is;
        std::string s;

        is.str( std::string( "1" ) );
        std::cout << is.str() << std::endl;
        is >> s;
        std::cout << s << std::endl;
        assert( s == "1" );

        is.str( std::string( "2" ) );
        std::cout << is.str() << std::endl;
        is >> s;
        std::cout << s << std::endl;
        assert( s == "2 ");
}

$ g++ iss.cpp -Wall -o iss && ./iss
1
1
2
1
iss: iss.cpp:20: int main(): Assertion `s == "2 "' failed.
Aborted


-- 
           Summary: operator >> loads wrong value after istringsstream::str(
                    string ).
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net


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


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