This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/47275] New: ofstream::put(255) results in bad stream when built with -fsigned-char on platforms that default to unsigned char
- From: "ceckak at frontier dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 13 Jan 2011 06:25:30 +0000
- Subject: [Bug libstdc++/47275] New: ofstream::put(255) results in bad stream when built with -fsigned-char on platforms that default to unsigned char
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47275
Summary: ofstream::put(255) results in bad stream when built
with -fsigned-char on platforms that default to
unsigned char
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ceckak@frontier.com
The program below runs without problems (no messages printed to stderr) on x86
linux when built with -fsigned-char or -funsigned-char (or with no flag).
On ARM and PowerPC, the same program fails at i=256 when built with
-fsigned-char, but runs without problems when built with -funsigned-char (or
with no flag).
Not entirely sure whether this is libstdc++ or a g++ bug, but seems likely that
it's an issue with the library.
-----
#include <iostream>
#include <fstream>
int main(void)
{
std::ofstream of;
of.open("tmp.bin");
if (!of.good())
{
std::cerr << "bad open(\"tmp.bin\")" << std::endl;
return 1;
}
for (int i = 0; i < 512; ++i)
{
of.put(i);
if (!of.good())
{
std::cerr << "bad put(" << i << ")" << std::endl;
return 1;
}
}
return 0;
}