[Info-vax] C and assembly language, was: Re: WHY IS VSI REQUIRING A HYPERVISOR FOR X86 OPENVMS?
David Jones
osuvman50 at gmail.com
Sat Dec 26 09:04:03 EST 2020
On Wednesday, December 23, 2020 at 11:31:42 AM UTC-5, xyzz... at gmail.com wrote:
> Consider a broken C routine that is declared "int" but one or more paths don't have a valid 'return' statement. On Alpha/Itanium, the value in R0/r8 is often the return value from a prior call to something. GEM doesn't really want to reuse R0/r8 for any kind of temporary since it won't live past the next routine call (it will use them if pushed into a corner). The return without a 'return' just gets you that prior R0/r8 value. If your 'int' routine is really a true/false routine, you might have been working for years without any problems.
>
> However, given the few registers on x86 (and how some of the instructions work), the return register %rax is used in many places for a short-term temporary. So when the C routine exits without a 'return' statement, the value in %rax can be very strange.
>
> The C program has been broken on every platform. If you would have used something like /WARNING=ENABLE=QUESTCODE, the compiler can help identify those paths without a 'return'. You can look for those broken programs today on Alpha or Itanium. [I've been tempted to promote that check out of the QUESTCODE category and have it enabled by default. That decision was done long ago before I was in a position to do anything to help.]
DECC's default settings have given warnings about that (%CC-W-MISSINGRETURN) for some time now, though it used to be an aggravating source of bugs.
More information about the Info-vax
mailing list