[Bug libstdc++/47275] New: ofstream::put(255) results in bad stream when built with -fsigned-char on platforms that default to unsigned char

2011-01-12 Thread ceckak at frontier dot com
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 
#include 

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;
}


[Bug libstdc++/47275] ofstream::put(255) results in bad stream when built with -fsigned-char on platforms that default to unsigned char

2011-01-12 Thread ceckak at frontier dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47275

--- Comment #1 from ceckak at frontier dot com 2011-01-13 06:40:17 UTC ---
Typo in the original description: fails at i=255 (not 256)


[Bug libstdc++/47275] ofstream::put(255) results in bad stream when built with -fsigned-char on platforms that default to unsigned char

2011-01-13 Thread ceckak at frontier dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47275

--- Comment #6 from ceckak at frontier dot com 2011-01-13 18:58:15 UTC ---
Fair enough.  Presumably it's just luck that this works on some toolchains
then?  Off to slog through a legacy codebase and sprinkle "signed char"
throughout...