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]

bug


// stl container
#include <vector>
#include <string>
#include <map>
#include <utility>

// io
#include <fstream.h>
the following source :
------------------------------------------------------------------------------------------------------
#include <iostream.h>
#include <strstream.h>

main (int argc, char **argv){  
    vector<string> commandtokens;
 
    commandtokens.push_back(string("first_long_string "));
    commandtokens.push_back(string("s2"));

    vector<string>::iterator commanditer = commandtokens.begin();

    string oneincre;
    string codesline=commanditer->data();
    cout << codesline<< endl; 
    istrstream ein(codesline.data());
    while(ein>>oneincre) cout << oneincre<< endl;    

    commanditer++;


    string codesline2=commanditer->data();
    cout << codesline2<< endl;
    istrstream zwei(codesline2.data());
    while(zwei>>oneincre) cout << oneincre<< endl; 		//prints wrong
result
    
    string codesline3=*commanditer;		// "*commanditer" is a workaround
for "commanditer->data()" 	
    cout << codesline3<< endl;
    istrstream drei(codesline3.data());
    while(drei>>oneincre) cout << oneincre<< endl;    
    
}
------------------------------------------------------------------------------------------------
is compiled with  
"g++ -v --save-temps " 
on   
$g++ -v
Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)    
$uname -a
Linux kroetz2 2.2.10 #14 Thu Nov 11 21:01:37 MET 1999 i586 unknown     

and produces the wrong output: 
-------------------------------------------------------------------------------------------------
$a.out
first_long_string
first_long_string
s2
s2rst_long_stri  //this should be "s2"
s2
s2                     
--------------------------------------------------------------------------------------------------

The source produces the right result on SGI IRIX 6.5 with SGI-Compiler.

Wieland Kroetz

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