This is the mail archive of the
libstdc++-prs@sources.redhat.com
mailing list for the libstdc++ project.
libstdc++/82: problem opening a stream in binary mode
- To: libstdc++-gnats at sourceware dot cygnus dot com
- Subject: libstdc++/82: problem opening a stream in binary mode
- From: wappenschmidt at digital-security dot com
- Date: 21 Aug 2000 16:25:41 -0000
- Reply-To: wappenschmidt at digital-security dot com
- Resent-Cc: libstdc++-prs at sourceware dot cygnus dot com
- Resent-Reply-To: libstdc++-gnats@sourceware.cygnus.com, wappenschmidt@digital-security.com
>Number: 82
>Category: libstdc++
>Synopsis: problem opening a stream in binary mode
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Aug 21 09:27:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Armin Wappenschmidt
>Release: libstdc++.so.2.10.0
>Organization:
>Environment:
gcc 2.95.2 on linux and solaris
>Description:
Opening a stream in binary mode doesn't work in this way:
ifstream in("binary.dat", ios::binary);
You can't read any values with ifstream::get().
Opening the binary with
ifstream in("binary.dat", ios::in|ios::binary);
does work correctly.
A similiar problems occurs while writing to a binary
stream. You have also to open it with "ios::out|ios::binary".
>How-To-Repeat:
>Fix:
Instead of
ifstream in ("binary.dat", ios::binary);
ofstream out("binary.dat", ios::binary);
use
ifstream in ("binary.dat", ios::in |ios::binary);
ofstream out("binary.dat", ios::out|ios::binary);
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-unknown-content-type-cppfile; name="tt.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="tt.cpp"
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KCnVzaW5nIG5hbWVzcGFjZSBz
dGQ7CgppbnQgbWFpbih2b2lkKQp7CiNpZiAwCiAgICBpZnN0cmVhbSBpbigiL2V0Yy9wYXNzd2Qi
LCBpb3M6OmlufGlvczo6YmluYXJ5KTsKI2Vsc2UKICAgIGlmc3RyZWFtIGluKCIvZXRjL3Bhc3N3
ZCIsIGlvczo6YmluYXJ5KTsKI2VuZGlmCgogICAgaWYgKCFpbikgewogICAgICAgIGNlcnIgPDwg
ImVycm9yIG9wZW5pbmcgZmlsZSIgPDwgZW5kbDsKICAgICAgICBleGl0KDEpOwogICAgfQogICAg
CiAgICB3aGlsZSAoICFpbi5lb2YoKSApIHsKICAgICAgICBjb3V0IDw8IGluLmdldCgpIDw8ICIu
IjsKICAgIH0KCiAgICBjb3V0IDw8IGVuZGw7CiAgICAKICAgIHJldHVybiAwOwp9Cg==