[Info-vax] C and assembly language
Stephen Hoffman
seaohveh at hoffmanlabs.invalid
Sat Dec 26 12:07:27 EST 2020
On 2020-12-26 14:04:03 +0000, David Jones said:
> 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.
Discussions of the Clang -Wall (variously with -Wpendant and/or -Wextra
added) versus the less-than-recommended -Weverything have a long
history, too.
Clang warnings:
https://quuxplusone.github.io/blog/2018/12/06/dont-use-weverything/
For those new to Clang: https://nus-cs1010.github.io/2021-s1/clang.html
For OpenVMS, /WARNING=ENABLE=QUESTCODE being lit by default wouldn't
bother me, as I tend to use that and /STANDARD=C99 or RELAXED lit, and
a few other switches.
Which usually then evolves into something akin to: /STANDARD=C99
/WARN=( ENABLE=( NOC99, OBSOLESCENT, DEFUNCT, QUESTCODE, ...),
DISABLE=(...))
I've found that OpenVMS C code still written with VAXC features tends
to have latent bugs, too. Code with /STANDARD=VAXC is code that should
be looked at. Stuff that I'm maintaining that has /STANDARD=VAXC lit
eventually doesn't have that switch anymore.
--
Pure Personal Opinion | HoffmanLabs LLC
More information about the Info-vax
mailing list