Path: utzoo!utgpu!water!watmath!clyde!rutgers!mcnc!rti!xyzzy!jonesjg From: jonesjg@xyzzy.UUCP (Greg Jones) Newsgroups: comp.sys.amiga Subject: Re: A bug in Lattice 4.0 Message-ID: <602@xyzzy.UUCP> Date: 9 Feb 88 06:08:03 GMT References: <1070@pembina.UUCP> Reply-To: jonesjg@xyzzy.UUCP () Organization: Data General Corporation, Research Triangle, NC Lines: 53 In article <1070@pembina.UUCP> andrew@alberta.UUCP (Andrew Folkins) writes: > > >I don't know about you, but if I compile & run this it's a guaranteed visit >from the guru. > >#include >#include > >struct testrec > { > char string1[16]; > }; > >struct testrec trec = { "Test1" }; > >void main() >{ > if (strlen(trec.string1) > 0) > printf("length = %d\n", strlen(trec.string1)); >} >Andrew Folkins ...ihnp4!alberta!andrew I ran into this last week and spent some time debugging it and have determined both the problem and a work around. I hope to file a STR this week sometime. The problem is in the statement if(strlen(anystring) >0) I used the omd to disassemble the code to discover an illegal instruction TST.L A2. This instruction is being used to check to see if strlen returns 0. The problem is the addressing mode (address register direct ?) is not allowed with the TST instruction. (note: all other modes are allowed). Well the workaround is easy ... 1) remember rev 4.00 has strlen as a builtin. So the workaround is to bypass the builtin version till Lattice fixes the bug by ... #ifdef strlen #undef strlen #endif Of course you could change the definition in the string.h include file. This would be a better solution, but the compressed include files complicates the process. Hope this helps ... -- Greg Jones Data General, RTP, NC jonesjg@dg-rtp.dg.com ...!seismo!mcnc!rti!dg-rtp!jonesjg