Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utah-gr.UUCP Path: utzoo!linus!decvax!harpo!utah-cs!utah-gr!thomas From: thomas@utah-gr.UUCP (Spencer W. Thomas) Newsgroups: net.bugs.4bsd,net.lang.c,net.unix-wizards Subject: Bug in 4.2Bsd C compiler Message-ID: <1143@utah-gr.UUCP> Date: Mon, 16-Jul-84 02:21:21 EDT Article-I.D.: utah-gr.1143 Posted: Mon Jul 16 02:21:21 1984 Date-Received: Tue, 17-Jul-84 06:24:35 EDT Distribution: net Organization: Univ of Utah CS Dept Lines: 32 Index: lib/ccom 4.2BSD Description: When casting an unsigned bit field to a signed integer, sign extension is done. Repeat-By: cc -S the following program. Note the ext instructions. Note also that this problem does not appear for full size unsigned ints. main() { int i; unsigned short j; struct { unsigned int a : 3; } a; i = a.a; i = (int)a.a; i = j; i = (int)j; } The (edited) output follows: _main: extzv $0,$3,_a,-4(fp) extv $0,$3,_a,-4(fp) movzwl -6(fp),-4(fp) movzwl -6(fp),-4(fp) ret