libstdc++/9563: ostream::sentry returns true after a failed preparation
sebor@roguewave.com
sebor@roguewave.com
Tue Feb 4 02:26:00 GMT 2003
>Number: 9563
>Category: libstdc++
>Synopsis: ostream::sentry returns true after a failed preparation
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Feb 04 02:26:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: sebor@roguewave.com
>Release: 3.2.1
>Organization:
>Environment:
>Description:
According to the requirements on the ostream::sentry ctor below, the program below should exit with the status of 0. It exits with 1 with gcc 3.2.1, indicating that the sentry ctor fails to check the state of the stream after the former has completed the preparation.
Regards
Martin
27.6.2.3:
-2- If os.good() is nonzero, prepares for formatted
or unformatted output. If os.tie() is not a null
pointer, calls os.tie()->flush().
-3- If, after any preparation is completed, os.good()
is true, ok_ == true otherwise, ok_ == false.
>How-To-Repeat:
$ cat t.cpp; g++ t.cpp && ./a.out ; echo $?
#include <ostream>
#include <streambuf>
struct buf: std::streambuf
{
std::ios *io_;
buf (std::ios *io): io_ (io) { }
virtual int sync () {
io_->setstate (std::ios::failbit);
return 0;
}
};
int main ()
{
buf b (0);
std::ostream strm (&b);
buf tb (&strm);
std::ostream tied (&tb);
strm.tie (&tied);
std::ostream::sentry s (strm);
return s;
}
1
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list