This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/5180: seekp() on fstreams opened in read only mode
- From: kingleo at gmx dot at
- To: gcc-gnats at gcc dot gnu dot org
- Date: 23 Dec 2001 16:33:05 -0000
- Subject: libstdc++/5180: seekp() on fstreams opened in read only mode
- Reply-to: kingleo at gmx dot at
>Number: 5180
>Category: libstdc++
>Synopsis: seekp() on fstreams opened in read only mode
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Dec 23 08:36:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Martin Oberzalek
>Release: gcc version 3.0.3
>Organization:
>Environment:
debian/linux/unstable on i386; glibc 2.2.4-7
>Description:
if a file is opened via std::fstream in read only mode,
and a seekp(0) will be done std::fstream::eof() will never
return true.
This causes the program to hang in a loop.
>How-To-Repeat:
just compile the program (no Optimation) and start it
by setting as the first option a simple text file.
$ echo "foobar" > foo && ./test_bug foo
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="main.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="main.cpp"
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4K
CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbiggaW50IGFyZ2MsIGNoYXIqKiBhcmd2ICkK
ewoKICBpZiggYXJnYyAhPSAyKQogICAgcmV0dXJuIDE7CgogIGZzdHJlYW0gaW4oIGFyZ3ZbMV0s
IHN0ZDo6aW9zOjppbiApOwogIAogIGlmKCAhaW4gKQogICAgewogICAgICBjb3V0IDw8ICJjYW5u
b3Qgb3BlbiBmaWxlICIgPDwgZW5kbDsKICAgICAgcmV0dXJuIDI7CiAgICB9CgogIGluLnNlZWtw
KDApOyAvLyA8PDw8PDw8CgogIHdoaWxlKCAhaW4uZW9mKCkgKQogICAgewogICAgICBzdHJpbmcg
czsKICAgICAgZ2V0bGluZSggaW4sIHMgKTsKICAgICAgY291dCA8PCBzIDw8IGVuZGw7OwogICAg
fQogICAgCiAgcmV0dXJuIDA7Cn07Cg==