This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/1704: Null output from Josuttis example
- To: gcc-gnats at gcc dot gnu dot org
- Subject: libstdc++/1704: Null output from Josuttis example
- From: pcarlini at unitus dot it
- Date: 19 Jan 2001 20:46:09 -0000
- Cc: bkoz at redhat dot com
- Reply-To: pcarlini at unitus dot it
>Number: 1704
>Category: libstdc++
>Synopsis: Null output from Josuttis example
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jan 19 12:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Paolo Carlini
>Release: gcc version 2.97 20010119 (experimental) or any snapshot in the last weeks
>Organization:
>Environment:
Intel PII, GLIBC2.2.1
>Description:
The following code (by N. Josuttis, p.669- of his book) does not produce the expected output (i.e. 31 HEXADECIMAL: 1F):
#include <iostream>
#include <streambuf>
#include <locale>
#include <cstdio>
class outbuf : public std::streambuf
{
protected:
/* central output function
* - print characters in uppercase mode
*/
virtual int_type overflow (int_type c) {
if (c != EOF) {
// convert lowercase to uppercase
c = std::toupper(c,getloc());
// and write the character to the standard output
if (std::putchar(c) == EOF) {
return EOF;
}
}
return c;
}
};
int main()
{
outbuf ob; // create special output buffer
std::ostream out(&ob); // initialize output stream with that output buffer
out << "31 hexadecimal: " << std::hex << 31 << std::endl;
}
>How-To-Repeat:
The next example in the book too (outbuf1x.cpp & outbuf1x.hpp) does not produce the expected output
P.S.: Thanks to Benjamin Kosnik for having fixed the bug I previously reported!
>Fix:
Dunno, unfortunately...
>Release-Note:
>Audit-Trail:
>Unformatted: