Return to BSD News archive
Newsgroups: comp.bugs.2bsd
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!world1.bawave.com!news2.cais.net!news.cais.net!news.mathworks.com!news.kei.com!nntp.coast.net!sgigate.sgi.com!rutgers!news.new-york.net!wlbr!moe!sms
From: sms@moe.2bsd.com (Steven M. Schultz)
Subject: C compiler 'no code table' error (#326)
Organization: 2BSD, Simi Valley CA USA
Message-ID: <DtCy1B.Bs1@moe.2bsd.com>
Date: Fri, 21 Jun 1996 16:05:35 GMT
Lines: 142
Subject: C compiler 'no code table' error (#326)
Index: lib/ccom/c10.c 2.11BSD
Description:
The code generation phase of the C compiler gives a "no code table"
error when dealing in certain cases for the unsigned long data type.
Repeat-By:
Attempt to compile the following program:
-----
#include <stdio.h>
#include <sys/types.h>
#define DEV_BSHIFT 10
#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
((u_long)(bytes) >> DEV_BSHIFT)
#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
((u_long)(db) << DEV_BSHIFT)
unsigned long ul;
long l;
long ll;
main()
{
ul = (long)btodb(ul); /* bombs */
ul = (long)dbtob(ul); /* works */
}
----
% cc -S x.c
18: No code table for op: >>(17) type: 6
Fix:
The problem is not that the compiler can not parse the code, but
rather that the code generation phase doesn't know how to deal with
the case of "shifting right an unsigned long inside an expression
of type long".
The optype 17 is "shift right unsigned long" but the type of 6 is
'long' (from the casting to (long)).
In c10.c the fix was simple and mirrors the code for the normal
(signed) long handling.
To install this update cut where indicated and save to a file
(/tmp/326). Then:
patch -p0 < /tmp/326
cd /usr/src/lib/ccom
make c1
mv /lib/c1 /lib/oc1
install -s -m 755 c1 /lib
After applying the fix the compiler may be tested on the sample
program:
Script started on Thu Jun 20 20:15:04 1996
% cc -S x.c
% cat x.s
.comm _ul,4
.comm _l,4
.comm _ll,4
.globl _main
.text
_main:
~~main:
jsr r5,csv
jbr L1
L2:mov $-12,-(sp)
mov 2+_ul,r1
mov _ul,r0
jsr pc,ulsh
tst (sp)+
mov r0,_ul
mov r1,2+_ul
mov 2+_ul,r1
mov _ul,r0
ashc $12,r0
mov r0,_ul
mov r1,2+_ul
L3:jmp cret
L1:jbr L2
.globl
.data
% exit
%
script done on Thu Jun 20 20:15:37 1996
No error and the generated code is correct.
This and previous updates for 2.11BSD are available via anonymous
FTP to either MOE.2BSD.COM or FTP.IIPO.GTEGSC.COM in the directory
/pub/2.11BSD.
-------------------------cut here----------------------------
*** /usr/src/lib/ccom/c10.c.old Tue Oct 4 21:15:59 1994
--- /usr/src/lib/ccom/c10.c Wed Jun 19 22:24:38 1996
***************
*** 1,5 ****
--- 1,8 ----
/*
* C compiler, part 2
+ *
+ * (long)btodb(l) produced 'no code table error for op: >>(17) type: 6'
+ * allow both long and ulong at line ~341. 1996/6/19
*/
#if !defined(lint) && defined(DOSCCS)
***************
*** 336,342 ****
*/
case ASULSH: /* 18 */
case ULSH: /* 17 */
! if (tree->t.type != UNLONG)
break;
if (tree->t.tr2->t.op==ITOL)
tree->t.tr2 = tree->t.tr2->t.tr1;
--- 339,345 ----
*/
case ASULSH: /* 18 */
case ULSH: /* 17 */
! if (tree->t.type != LONG && tree->t.type != UNLONG)
break;
if (tree->t.tr2->t.op==ITOL)
tree->t.tr2 = tree->t.tr2->t.tr1;
*** /VERSION.old Wed Jun 19 21:36:08 1996
--- /VERSION Thu Jun 20 20:16:39 1996
***************
*** 1,4 ****
! Current Patch Level: 325
2.11 BSD
============
--- 1,4 ----
! Current Patch Level: 326
2.11 BSD
============