🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2859

unsigned conversion

#2859
From: Karl Berry
Date: Fri, 09 Feb 1990 01:58
30 lines
1050 bytes
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
Technical Details
Message-ID: <9002090158.AA02108@claude.>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!uunet!bu.edu!bu-cs!lll-winken!sol.ctr.columbia.edu!cica!tut.cis.ohio-state.edu!claude.umb.edu!karl

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!uunet!bu.edu!bu-cs!lll-winken!sol.ctr.columbia.edu!cica!tut.cis.ohio-state.edu!claude.umb.edu!karl
From: karl@claude.umb.edu (Karl Berry)
Newsgroups: gnu.gcc.bug
Subject: unsigned conversion
Message-ID: <9002090158.AA02108@claude.>
Date: 9 Feb 90 01:58:59 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 30