CompuServe Thread

#Problems w/proc RETURNs

4 messages in this thread
#14225From: Paul WhittemoreDec 30, 1989 5:32 PM
Hi Leon, Been having a problem that only you may be able to solve… Any other development environment and I'd say it's bad code from the compiler, but in your case (BM), I know that's VERY unlikely to say the least. My problem(s) are with PROCEDURE returns. My original problem was with a boolean procedure in which under one condition, the code would just run off the END. This was a bug, but I would assume that the return value is simply undefined. Instead, when the code hit the END rather than a RETURN, the program HALTed. This one I solved by simply fixing my bug (adding a RETURN TRUE). The one I cannot solve is a simple case of an INTEGER procedure and a RETURN (of a -5). Seems to have worked fine in the past, but now, as in the missing return case above, it ventures off into never-never land. The obvious guess would be stack corruption, but I don't think I've changed this code at all since it worked, and it's pretty heavily exercized anyhow… Just wanted to bounce it off you in case you had any other suspicions or suggestions. Thanx, Paul
#14242From: Avant-Garde SoftwareDec 30, 1989 11:31 PM
Hi Paul: Let me make a very simple suggestion, fire-up the Source Level Debugger and trace through the code watching the assembly language window. Maybe even drop into ASM mode if necessary. Also, the HALT was occuring due to Range-Checking being turned on, I would recommend turning it off. Happy New Year! >> Leon Frenkel <<
#14252From: Paul WhittemoreDec 31, 1989 2:00 PM
Thanx Leon, Range-checking WAS on. I'll turn it off and see what happens. BTW, I DID trace through it in ASM mode and didn't see anything unusual, but I was looking for TRAPs and other (very) unusual instructions. If I still have a problem after turning off range-checking, I'll have to take a second look at the ASM. Thanx again, Paul Whittemore [72007,3305]
#14253From: Paul WhittemoreDec 31, 1989 3:02 PM
Hi Leon, follow-up to my previous message: I turned range-checking off for a quick check and sure enough, it solved my problem. The code worked correctly. So I started thinking about the range error and decided that I should leave range-checking on and fix the bug rather than band-aid it by turning the checking off. So I checked the RETURN and found it was as follows: RETURN tNum; where 'tNum' was declared via CONST tNum = -5; So I figured that I declared the procedure as a CARD or LONGCARD or something but when I checked it was PROCEDURE : INTEGER. So as far as I can see, there's no range error. Now my best guess is that the compiler sign-extends CONSTs when they're declared and tried to return -5D rather than -5. Does this sound plausible? And is there some way in a CONST declaration to explicitly state that a constant is a WORD (ala 'D' for LONGWORDs)? Thanx again, Paul Whittemore [72007,3305]