I used keil c to compile my program. When I deleted a unused function, it procuce the ERROR L138: CODE GENERATION: PROBLEM WHEN PROCESSING INSTRUCTIONS CAUSE: JUMP TARGET OUT OF RANGE ADDRESS: 047E6H But when I didn't delete the function, compile successfully. Who can tell me the reason? I am sure the program didn't use the function.
Which toolset version are you using?
The compiler is uVision2, the version is C Compiler: C51.exe v7.06 Linker: LX51.exe v3.58
This are not up-to-date versions. Do you have a service contract that allows you to upgrade to the current release? Reinhard
What is the version of the newest uVision2?
http://www.keil.com/update/c51.asp
I've run across a similar bug a couple of times in 7.50a. It seems to be related to the dead code removal, in conjunction with linker common code optimizations. The linker will only partially remove unused code. A routine that isn't called will be left behind for some reason; that routine calls a ?L?COMxxx function that has been created by the optimizer and (properly) removed. The linker generates a jump target out of range error (as opposed to, say, unresolved external) when this happens. The target is the ?L?COMxxx stub, which makes it fun to debug, as the only way to find the address in the error is to look in the .cod file. The missing code doesn't correspond directly to source, after all. I've seen this twice, in two separate projects. We've tried to put together the proverbial small project that demonstrates the problem for tech support, but haven't managed to produce the problem on a small scale. (The bug might only show up in complex projects, of course.)
Drew, the problem that you describe should be fixed in Version 8. Reinhard