svn commit: trunk/uClibc: include

Rob Landley rob at landley.net
Thu Jan 8 07:35:57 UTC 2009


On Wednesday 07 January 2009 21:16:17 Denys Vlasenko wrote:
> On Wednesday 07 January 2009 13:33, Peter Kjellerstedt wrote:
> > This has (almost) been tried before. Then it was -fsigned-char,
> > but I think this thread from 2007 still bears meaning (especially
> > Mike's mail):
> >
> > http://lists.busybox.net/pipermail/uclibc/2007-April/038622.html
>
> this one:
> > > that enabled -fsigned-char for all arches. What was the reasoning
> > > behind this decision? I'm reliably informed that it generates
> > > suboptimal code on our architecture.
> >
> > what dumbass committed that change !
>
> But -funsigned-char is much more safe than signed one.
> Point me to a bug (in any program not just uclibc)
> which happens with unsigned chars but works with signed ones.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  for(;;) {
    unsigned char c = fgetc(stdin);
    if (c == EOF) {
      printf("Walrus\n");
      exit(0);
    }
    putchar(c);
  }
}

Remove the "unsigned" and it works fine.

Not saying it's good code, but you asked for a behavior change that happens 
out in the wild.

I also note that tinycc required -fsigned-char and if you gave it -funsigned-
char it miscompiled stuff.  I never did track down why...

Rob


More information about the uClibc mailing list