Path: utzoo!attcan!uunet!zephyr.ens.tek.com!uw-beaver!mit-eddie!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpda!hpcuhb!hpcllla!hpclisp!hpcljms!brians From: brians@hpcljms.HP.COM (Brian Sullivan) Newsgroups: comp.sys.amiga.tech Subject: Re: Bug in Lattice C 5.04 (IBM host) Message-ID: <9890005@hpcljms.HP.COM> Date: 5 Sep 90 22:07:03 GMT References: <33535@cup.portal.com> Organization: Hewlett-Packard Calif. Language Lab Lines: 31 > I found a major bug in Lattice C 5.04 for the IBM host, which is supposed > to be identical to the native version, but I guess not. The bug: > > LONG value; > > switch (value) { > case 0: > DoSomething(); > break; > case 0x100000000 > DoFoo(); > break; > } > > whether value is 0 or 100000000, DoSomething() executes. When I looked at > a disassembly from OMD, it was clear that in the 2nd case, the code was > checking for equality to 0! I am going to call Lattice about this, > and will post further afterwards. > > Nicky Robinson > What do you really expect the compiler to do? It should give you an error message or warning about "hex constant too large", but otherwise the compiler is simply doing what it should. You hex constant 0x100000000, is too large to fit into a 32-bit storage container. I suspect that the compiler parser is scaning the constant digit by digit, multiplying by 16 each time and adding the new digit value. You program is clearly in error, since hex constants can be at most 8 hex digits long.