This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/28103] New: std::operator<<(ostream&, string) sets badbit instead of failbit on failure
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2006 18:14:31 -0000
- Subject: [Bug libstdc++/28103] New: std::operator<<(ostream&, string) sets badbit instead of failbit on failure
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
21.3.7.9, p4 requires the operator to set failbit, not badbit, on failure. This
came up while I was gathering background for c++std-lib-17241.
$ cat ~/tmp/t.cpp && g++ ~/tmp/t.cpp -static && ./a.out
#include <cassert>
#include <cstdio>
#include <string>
#include <strstream>
int main ()
{
char buf [3];
std::ostrstream os (buf, sizeof (buf));
os << std::string ("1234");
std::printf ("state = %c%c%c (expected --?)\n",
os.rdstate () & os.badbit ? 'B' : '-',
os.rdstate () & os.eofbit ? 'E' : '-',
os.rdstate () & os.failbit ? 'F' : '-');
std::fflush (stdout);
assert (!(os.rdstate () & os.badbit));
}
In file included from
/usr/local/gcc-4.1.0/lib/gcc/sparc-sun-solaris2.9/4.1.0/../../../../include/c++/4.1.0/backward/strstream:51,
from /nfs/b20/sebor/tmp/t.cpp:4:
/usr/local/gcc-4.1.0/lib/gcc/sparc-sun-solaris2.9/4.1.0/../../../../include/c++/4.1.0/backward/backward_warning.h:32:2:
warning: #warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section 17.4.1.2
of the C++ standard. Examples include substituting the <X> header for the <X.h>
header for C++ includes, or <iostream> instead of the deprecated header
<iostream.h>. To disable this warning use -Wno-deprecated.
state = B-- (expected --?)
Assertion failed: !(os.rdstate () & os.badbit), file /nfs/b20/sebor/tmp/t.cpp,
line 21
Abort (core dumped)
--
Summary: std::operator<<(ostream&, string) sets badbit instead of
failbit on failure
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
GCC build triplet: all
GCC host triplet: all
GCC target triplet: all
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28103