Fix sign extension in cpplex.c

Neil Booth neil@daikokuya.demon.co.uk
Tue Feb 5 11:11:00 GMT 2002


Ulrich Weigand wrote:-

> Andreas Jaeger wrote:
> 
> >int
> >main (void)
> >{
> >  signed char c = '\xff';
> >  unsigned char d = '\xff';
> >
> >  return 0;
> >}
> 
> (gcc.dg/cpp/charconst-2.c)
> 
> This case fails on s390 (and presumably every architecture where char is
> unsigned) with a warning
>   "overflow in implicit constant conversion"
> in the line
>   signed char c = '\xff';
> 
> >From my reading of the standard, the warning appears correct as
> the integer character constant '\xff' has the value 255 on an
> implementation where char is unsigned (and 8-bit).  This value
> is indeed too large to represent in a variable of type 'signed char'.
> 
> Is this a bug in test case (or was the warning incorrect after all)?

It looks to me like Andreas' bug fix was correct, but that the test case
is bogus on some archs like you say.

Neil.



More information about the Gcc-patches mailing list