karl@claude.umb.edu (Karl Berry) (02/09/90)
This is with gcc 1.36, on any of a 386, Sun 3, or Sparc
(I doubt the machine matters).
As I understand it, integer values should be converted
to unsigned values in (almost?) all contexts.
The following program demonstrates that a -1 is
not being converted to unsigned. I think.
struct {
short rr;
unsigned char cc;
} a [257];
unsigned short b[257];
main ()
{
a[0].rr = -1;
b[45] = 231;
if (a[0].rr > b[45])
printf ("-1 was > 231.\n");
else
printf ("231 was > -1.\n");
}
With cc, -1 is > 231. With gcc, 231 is > -1.
(if b is not an array, then the -1 is indeed converted.)
karl@cs.umb.edu