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: unassig...@gcc.gnu.org ReportedBy: cec...@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; }