Re: c++ question regarding tellg()


Subject: Re: c++ question regarding tellg()
From: Jim Cole (greyleaf@yggdrasill.net)
Date: Thu Jan 10 2002 - 01:35:46 MST


Hi - I think the stringstream/stringbuf code is somewhat broken.
An official GCC implementation didn't exist until 2.95.3, so it
is relatively new. Tracing through the code, it appears that the
stringbuf's pbase pointer is always null when str() is called.
This problem isn't unique to YDL distributions. Under gcc3, the
results of your code snippet look reasonable.

tellg() 1
string buf = John
length of buf = 4
John

In any case, I don't think it has anything to do with missing
rpm's.

Jim

John Schmidt's bits of Wed, 9 Jan 2002 translated to:

>Hi,
>
>I am wondering why the tellg() is only declared in iostream.h in the following
>rpms:
>
>gcc-2.95.4-4h
>gcc-c++-2.95.4-4h
>gcc-g77-2.95.4-4h
>
>Using gcc on an SGI, things appear to work but not on my ydl 2.1 version with
>the latest g++ compiler.
>
>Here is the sample code stream_test.cc
>
>#include <iostream>
>#include <sstream>
>#include <string>
>
>using namespace std;
>
>int main()
>{
> string name("John");
> istringstream instream(name);
> instream.seekg(1);
> cout << "tellg() " << instream.tellg() << endl;
> cout << "string buf = " << instream.rdbuf()->str() << endl;
> cout << "length of buf = " << instream.rdbuf()->str().size() << endl;
> cout << name << endl;
> return 0;
>}
>
>compiling with: c++ -o stream_test stream_test.cc
>
>and running: ./stream_test results in the following:
>
>[jas@retriever jas]$ ./stream_test
>tellg() 268526225
>string buf =
>length of buf = 0
>John
>
>This is clearly not right. Am I missing some development rpms or is the g++
>compiler for ppc not complete in this regard.



This archive was generated by hypermail 2a24 : Thu Jan 10 2002 - 01:51:09 MST