[net.bugs.4bsd] C fails to optimize a function's last expression -- Fix

gnu@l5.uucp (John Gilmore) (09/07/85)

(I've redirected followups to net.lang.c where this discussion should be.)

The problem where the last expression doesn't get optimized is a
communications proglem between ccom and c2, exacerbated by a bug in
your source.

The source bug is that you defined a function that returns "int" (by
default) and didn't provide a return statement.  Unfortunately, lint
doesn't complain about this, so nobody ever fixes it.

The communications proglem is that ccom doesn't tell c2 when there is
a return statement and when there isn't.  C2 is forced to assume that
on any return-from-subroutine, the result register(s) must be preserved.

Richard Tuck half-fixed the problem at Sun by having ccom tell c2
whether the procedure is declared to return a value.  This only works
if your source is free of the above bug, and since "void" hasn't
existed forever and doesn't work in various systems, there's plenty
of source that still has the bug.