(Sorry for extra delay, I misplaced this.)
On 2010-04-16 08:47:16 -0500, (e-mail address removed) said:
I believe I've heard of implementations where a mismatched return
type will indeed produce spectacular failures -- say, if someone
tries to call a function returning int, but the function actually
called returns void, the return goes to the wrong place entirely
and Bad Stuff Happens.
Haven't seen one, usually all I see is stack garbage. Although
that can produce surprises sometimes too.
Mismatched type -- declaring something to return T1 when it actually
returns T2 -- is one error. Declaring the right type (or near enough,
e.g. short vs int on a machine where both are returned in the same
register) but returning an undefined value by falling off the end or
C89 return with no expression is a different error.
All implementations I've seen return struct types, except sometimes
quite small ones, and sometimes other 'unusually' large types such as
'quad real' or complex, via a hidden pointer argument, so misdeclaring
one of those return types can certainly cause real trouble. AFAIK all
C implementations for x86 at least normally return floating point in
x87/FPU reg rather than integer reg(s) -- at least real, I haven't
tried any C99 complex yet -- so a misdeclaration gives garbage, but
I've never seen them rely on other x87 stack elements over such a call
which could affect downstream, although it could be I just write code
that is too well structured and straightforward <G?>.
I've used a machine where the CPU (general) registers are stacklike
and 16bits, and the callsite wrongly expecting e.g. short vs long,
could cause bizarreness later. But the C compiler on that machine
'fixed' it by generating an extra instruction to force the regstack to
the expected size, albeit possibly a garbage content, apparently
because this was (too) common in realworld programs.
As noted VMS had a huge set of defined error/status values, so if your
garbage main return hit a quasirandom one DCL might *say* things like
"main power failed" or "system fire alarm". But these things hadn't
actually happened, your garbage status just claimed they had.