[Info-vax] C and assembly language, was: Re: WHY IS VSI REQUIRING A HYPERVISOR FOR X86 OPENVMS?
Simon Clubley
clubley at remove_me.eisner.decus.org-Earth.UFP
Sat Dec 26 06:09:31 EST 2020
On 2020-12-23, John Reagan <xyzzy1959 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.
>
Interesting. I don't suppose we would happen to know the C program in
question ? :-)
> 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.]
The move to LLVM is your opportunity to do just this.
Besides, people should be compiling production code with warnings enabled
anyway and fixing the warnings, so you would just be helping to enforce
this practice.
Simon.
--
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
More information about the Info-vax
mailing list