Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site elsie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.bugs.4bsd Subject: Re: cc generated code bug Message-ID: <5157@elsie.UUCP> Date: Tue, 9-Jul-85 18:26:44 EDT Article-I.D.: elsie.5157 Posted: Tue Jul 9 18:26:44 1985 Date-Received: Thu, 11-Jul-85 08:28:29 EDT References: <486@tjalk.UUCP> Organization: NIH-LEC, Bethesda, MD Lines: 29 Summary: shifting of signed entities can mess up too In article <486@tjalk.UUCP>, cogito@tjalk.UUCP (Robbert van Renesse) writes: > When right-shifting an unsigned variable, the compiler generates an > EXTZV instruction. If the shift count exceeds 32, a reserved operand > fault occurs and the program gets an illegal instruction signal, instead > of giving a null result. The problem goes beyond unsigned variables. When right-shifting a signed variable, the compiler generates an ASHL instruction, which takes a byte as its shift count. If the shift count's magnitude is too large, things go awry, as compiling and running the following source shows: #includemain() { int i; i = 5; printf("%d\n", i >> 257); } As to whether the illegal instruction or the bogus answer is the bigger problem. . . -- Bugs is a Warner Brothers trademark. CC is a Canadian Club trademark. -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX and Elsie are Digital Equipment and Borden trademarks