Text File

Aucbvax.2502 fa.unix-wizards utzoo!decvax!ucbvax!naha@LL-ASG Fri Jul 31 12:30:57 1981 bug in v7 C compiler From: naha at LL-ASG (Mark Nahabedian) The version 7 C compiler causes sign extension to be performed when one casts an unsigned integer to a long when innitializing variables.

As a test, consider the source program

long a = (long) 0177777; long b = (long) (unsigned int) 0177777; long c = 0177777L; long x; int y = 0177777; unsigned int z = 0177777; foo() { x = (long) y; x = (long) z; }

which produces the assembler input

.globl _a .data _a: 177777; 177777 .globl _b .data _b: 177777; 177777 .globl _c .data _c: 0; 177777 .comm _x,4 .globl _y .data _y: 177777 .globl _z .data _z: 177777 .globl _foo .text _foo: ~~foo: jsr r5,csv jbr L1 L2:mov _y,2+_x sxt _x mov _z,2+_x clr _x L3:jmp cret L1:jbr L2 .globl .data

Note that in the case of actual assingmet at run-time it sign extends when it should and doesn't when it shouldn't.

When it innitializes the variable b, it converts -1 integer to -1 long even when it has been explicitly told that the -1 integer is really an unsigned 0177777 integer.

Any ideas about why it does this or how it could be fixed?

-----

----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen <jgoerzen@complete.org> 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.