Autzoo.1481
net.bugs.v7
utcsrgv!utzoo!henry
Thu Mar 11 17:29:19 1982
(unsigned)char
Casting a char value to unsigned in the V7 compiler does a very nice
job of something that is awkward to get otherwise:  zero-extending
rather than sign-extending a char.  The trouble is, that's a bug:  be
warned.  The official behavior of casts, according to DMR, is that
they act like assignment to a temporary variable of that type.  Which
means that casting char to unsigned goes via int the same way a normal
assignment does, and the sign gets extended.  This is fixed in DMR's
more recent C compilers (when I asked him, he wasn't sure whether the
3.0 compiler was recent enough).

-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <[email protected]>
of http://communication.ucsd.edu/A-News/


This Usenet Oldnews Archive
article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.