Path: utzoo!censor!geac!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!kth.se!news From: wahlsten@elixir.lne.kth.se (Jorgen Wahlsten) Newsgroups: comp.os.minix Subject: Re: c68 has a switch bug Message-ID: <1991Mar1.152858.29005@kth.se> Date: 1 Mar 91 15:28:58 GMT References: <1087@mwtech.UUCP> Organization: Dept. of EE, Royal Institute of Technology, Stockholm, Sweden Lines: 41 In article <1087@mwtech.UUCP> joerg@mwtech.UUCP (Joerg Werner) writes: > >I use c68 all the time and I like it. But after I compiled the >complete Minix-ST 1.5 operating system, mdb (the Minix debugger) >doesn't work any longer. > >Please have a look at the following programm: > [...] The bug is in genstmt.c when generating code for the 'switch'-statement. The expresseion in switch(expr) is assumed to be unsigned (somehow), so when you have an short int, 'i' in your example c68 never cast'ed it into a long before looking up the value (it became 65535L instead of -1). This only happens when you use more than 7 case-statements, that is, when c68 generates a long-table with addresses instead of cmp/jmp... I've made a modif. that (i think) work but i haven't tested it that much, and i'm not sure my modification respects all there is (Better have CvW confirm). But for a quick and easy change, use the diff that follows... Regards, /wahlsten@lne.kth.se output from 'diff genstmt.c genstmt.c.org': ---------- Cut here! ---------- 362d361 < enum e_bt ctyp; 377d375 < ctyp = stmt->exp->etype; 411d408 < if (size == 1 || size == 2) 413,419d409 < ap = g_cast(ap, ctyp, bt_long, F_DREG | F_VOL); < #endif < #ifdef INTEL_386 < ap = g_cast(ap, ctyp, bt_long, F_REG); < #endif < /* < #ifdef MC680X0 431d420 < */