public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/4433: strstream::{tellp,seekp} fail.
@ 2002-04-09 12:54 bkoz
  0 siblings, 0 replies; 2+ messages in thread
From: bkoz @ 2002-04-09 12:54 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, nobody, ymedini, yotam_medini

Synopsis: strstream::{tellp,seekp} fail.

Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Tue Apr  9 12:54:39 2002
Responsible-Changed-Why:
    Mine.
State-Changed-From-To: open->closed
State-Changed-By: bkoz
State-Changed-When: Tue Apr  9 12:54:39 2002
State-Changed-Why:
    The strstream interface is deprecated, and as Paolo notes below, and the libstdc++-v3 strstring interface does not conform to the standard-approved stringstream interface. (They are different classes.)
    
    Of interest is the use of stringstreams instead of strstreams in your sample code. If strstream->sstream, and std::strstream->std::stringstream substitutions are performed on your code, everything is ok and you'll get the results you expect.
    
    Thus, I conclude that this is not a bug.
    
    %a.out 
    ok=1
    
    -benjamin

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4433


^ permalink raw reply	[flat|nested] 2+ messages in thread

* libstdc++/4433: strstream::{tellp,seekp} fail.
@ 2001-10-01  5:16 ymedini
  0 siblings, 0 replies; 2+ messages in thread
From: ymedini @ 2001-10-01  5:16 UTC (permalink / raw)
  To: gcc-gnats; +Cc: yotam_medini

>Number:         4433
>Category:       libstdc++
>Synopsis:       strstream::{tellp,seekp} fail.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 01 05:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Yotam Medini
>Release:        3.0.1 (also 2.95.2 )
>Organization:
>Environment:
Linux
>Description:
Writing strstream.
Then two after 3 ::seeks(...)
then ::tellp() returns wrong position.
>How-To-Repeat:
just compile and run.
In case Netscape failed to unload, here is seektell.cc:
#include <iostream>
#include <strstream>

namespace std {}; using namespace std;

static bool chekpos(const char* msg, std::iostream& strm, int expectedPos)
{
   int  pos = strm.tellp();
   bool  ok = (pos == expectedPos);
   if (!ok)
   {
      cerr << msg << " pos=" << pos << 
              " != " << expectedPos << " [expected]" << endl;
   }
   return ok;
}

int main(int argc, int argv)
{
   bool            ok = true;
   std::strstream  strm;
   const unsigned  l1 = 10;
   char*           data = new char[l1];
   for(unsigned i=0; i<l1; i++) data[i] = 'a'+i;
   strm.write((const char*)data, l1);
   // delete [] data;

   strm.seekp(0, std::ios::end);
   ok = chekpos("check1: seek(0, end)", strm, l1) && ok;

   strm.seekp(-4, std::ios::cur);
   ok = chekpos("check2: seek(-4, cur)", strm, l1-4) && ok;

   strm.seekp(0, std::ios::end);
   ok = chekpos("check3: seek(0, end)", strm, l1) && ok;

   cout << "ok=" << ok << endl;
   return !ok;
} // main
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="seektell.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="seektell.cc"

I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3Ryc3RyZWFtPgoKbmFtZXNwYWNlIHN0ZCB7
fTsgdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0YXRpYyBib29sIGNoZWtwb3MoY29uc3QgY2hhciog
bXNnLCBzdGQ6Omlvc3RyZWFtJiBzdHJtLCBpbnQgZXhwZWN0ZWRQb3MpCnsKICAgaW50ICBwb3Mg
PSBzdHJtLnRlbGxwKCk7CiAgIGJvb2wgIG9rID0gKHBvcyA9PSBleHBlY3RlZFBvcyk7CiAgIGlm
ICghb2spCiAgIHsKICAgICAgY2VyciA8PCBtc2cgPDwgIiBwb3M9IiA8PCBwb3MgPDwgCiAgICAg
ICAgICAgICAgIiAhPSAiIDw8IGV4cGVjdGVkUG9zIDw8ICIgW2V4cGVjdGVkXSIgPDwgZW5kbDsK
ICAgfQogICByZXR1cm4gb2s7Cn0KCmludCBtYWluKGludCBhcmdjLCBpbnQgYXJndikKewogICBi
b29sICAgICAgICAgICAgb2sgPSB0cnVlOwogICBzdGQ6OnN0cnN0cmVhbSAgc3RybTsKICAgY29u
c3QgdW5zaWduZWQgIGwxID0gMTA7CiAgIGNoYXIqICAgICAgICAgICBkYXRhID0gbmV3IGNoYXJb
bDFdOwogICBmb3IodW5zaWduZWQgaT0wOyBpPGwxOyBpKyspIGRhdGFbaV0gPSAnYScraTsKICAg
c3RybS53cml0ZSgoY29uc3QgY2hhciopZGF0YSwgbDEpOwogICAvLyBkZWxldGUgW10gZGF0YTsK
CiAgIHN0cm0uc2Vla3AoMCwgc3RkOjppb3M6OmVuZCk7CiAgIG9rID0gY2hla3BvcygiY2hlY2sx
OiBzZWVrKDAsIGVuZCkiLCBzdHJtLCBsMSkgJiYgb2s7CgogICBzdHJtLnNlZWtwKC00LCBzdGQ6
Omlvczo6Y3VyKTsKICAgb2sgPSBjaGVrcG9zKCJjaGVjazI6IHNlZWsoLTQsIGN1cikiLCBzdHJt
LCBsMS00KSAmJiBvazsKCiAgIHN0cm0uc2Vla3AoMCwgc3RkOjppb3M6OmVuZCk7CiAgIG9rID0g
Y2hla3BvcygiY2hlY2szOiBzZWVrKDAsIGVuZCkiLCBzdHJtLCBsMSkgJiYgb2s7CgogICBjb3V0
IDw8ICJvaz0iIDw8IG9rIDw8IGVuZGw7CiAgIHJldHVybiAhb2s7Cn0gLy8gbWFpbgo=


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-04-09 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-09 12:54 libstdc++/4433: strstream::{tellp,seekp} fail bkoz
  -- strict thread matches above, loose matches on Subject: below --
2001-10-01  5:16 ymedini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).