funny strstream bug (yes I know it's deprecated)

Brian Bull b.bull@niwa.cri.nz
Thu Jan 10 20:16:00 GMT 2002


People probably don't care about strstream any more but I still 
thought this was an interesting one.

Self contained bug example follows:

---------------------------------------
#include <string>
#include <strstream>

int main(){
  std::string fred = "                
some_spaces_precede_a_single_exceedingly_long_word 1 ";
  istrstream arguments((fred+" ").c_str());
  std::string base;
  arguments >> base;
  int L;
  arguments >> L;
  cerr << "L " << L << '\n';
}

// Expected output: L 1
// Actual output on my system: L 0  (??!!)
----------------------------------------

Puzzlingly, the code can be made to work by replacing the words 
'exceedingly long' by 'short' in std::string fred. 

I'm running today's download of Cygwin and gcc on Win2000.

Any enlightenment welcome.

Yours
Brian Bull 



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list