Bug 54820

Summary: seekp moves backward, but not forward, in ostrstream
Product: [Retired] Red Hat Linux Reporter: davidwriter
Component: libstdc++Assignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: teg
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-12-15 17:57:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
C++ file testing seekp
none
C++ standard version of the example code, working fine none

Description davidwriter 2001-10-19 18:54:29 UTC
Description of Problem:


Version-Release number of selected component (if applicable):
g++ 2.96-85

How Reproducible:
Every time

Steps to Reproduce:
1.  Compile program with g++ -Wall  testseek.cpp -o testseek
2. Run
3. 

Actual Results:seekp test
Posn after 1st write : 1020
Posn after 1st move : 100
Posn after 2nd move : 100
 Bad bit set
Posn after 3rd move : 0

Expected
Posn after 1st write : 1020
Posn after 1st move : 100
Posn after 2nd move : 300
Posn after 3rd move : 0

 Results:
Legacy code fails as seekp is not working

Additional Information:

Comment 1 davidwriter 2001-10-19 18:56:45 UTC
Created attachment 34423 [details]
C++ file testing seekp

Comment 2 Mike A. Harris 2001-11-25 01:51:05 UTC
David, as I mentioned on enigma-list, I don't personally know 
C++ to know wether or not this is a bug, however, I have
just confirmed the results above if that helps:

pts/16 mharris@zod:~$ ./testseek
seekp test
Posn after 1st write : 1020
Posn after 1st move : 100
Posn after 2nd move : 100
 Bad bit set
Posn after 3rd move : 0
pts/16 mharris@zod:~$ rpm -qf /usr/bin/g++
gcc-c++-2.96-95


pts/0 mharris@halden:~$ ./testseek
seekp test
Posn after 1st write : 1020
Posn after 1st move : 100
Posn after 2nd move : 100
 Bad bit set
Posn after 3rd move : 0
pts/0 mharris@halden:~$ cat /etc/redhat-release
Red Hat Linux release 7.2 (Enigma)
pts/0 mharris@halden:~$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)

Hope this helps.

Comment 3 Michael Schwendt 2002-01-12 17:46:44 UTC
Converting from non-standard "ostrstream" to standard "ostringstream" (header
<sstream>) yields expected behaviour:

$ rpm -q gcc-c++
gcc-c++-2.96-98

$ ./testseek2
seekp test2
Posn after 1st write : 1020
Posn after 1st move : 100
Posn after 2nd move : 300
Posn after 3rd move : 0


Or, using GCC3 and libstdc++ v3 yields expected behaviour in both cases, too:

$ rpm -q gcc3-c++
gcc3-c++-3.0.1-3

$ ./testseek
seekp test
Posn after 1st write : 1020
Posn after 1st move : 100
Posn after 2nd move : 300
Posn after 3rd move : 0

$ ./testseek2
seekp test2
Posn after 1st write : 1020
Posn after 1st move : 100
Posn after 2nd move : 300
Posn after 3rd move : 0


Comment 4 Michael Schwendt 2002-01-12 17:48:21 UTC
Created attachment 42331 [details]
C++ standard version of the example code, working fine

Comment 5 Alan Cox 2002-12-15 17:57:35 UTC
Ok in 3.2