[PATCH] Preserve noreturn attribute of _Exit and _exit

Roger Sayle roger@eyesopen.com
Wed Jul 10 19:14:00 GMT 2002


On Wed, 10 Jul 2002, Richard Henderson wrote:
> On Sat, Jul 06, 2002 at 03:15:22PM -0600, Roger Sayle wrote:
> > Mysteriously,  there is explicit code to do this in
> > duplicate_decls.  The bug is fixed by removing this
> > special case.
>
> Hum.  Do you see who added this code and why?  I suspect
> your patch is correct, but want to know why things are as
> they are.

I bit of archeology reveals that the code in questions predates
the CVS repository.  Digging deeper in ftp.gnu.org/old-gnu/gcc
the code was in gcc-2.5.8 but not in gcc-1.42.  Relying on the
ChangeLogs, I believe these lines were written by RMS in the
following patch:

Mon Jan 13 00:26:47 1992  Richard Stallman  (rms at mole.gnu.ai.mit.edu)

        * c-decl.c (shadow_tag): For useless keyword, just warn.
        (duplicate_decls): Don't preserve volatile bit from old decl
        if that is just a default declaration for abort, exit, etc.

which means it was introduced just before gcc 2.0 was released.
This unfortunately means there isn't a diff confirming this was
indeed the release that introduced it.


I'm guessing the semantics of DECL_BUILT_IN_NONANSI have changed in
the last ten years, as the "abort" and "exit" functions mentioned
in the ChangeLog are now ANSI.  In fact, the noreturn attribute was
applied to "abort", "exit" and "_exit" for the first time only a few
weeks earlier:

Tue Dec 24 20:41:32 1991  Richard Stallman  (rms at mole.gnu.ai.mit.edu)

        * c-decl.c (init_decl_processing):
        Declare abort, exit, and _exit as volatile.

[Not everyone commits patches to GCC after 10pm on Christmas Eve!]


Is it safe to assume that this code predates the current GCC semantics
that builtin function attributes are "sticky"?  We currently allow "abort"
and "exit" to be prototyped without __attribute__((noreturn)) but loose
this attribute on "_exit".  I'm guessing RMS intended them to be treated
identically, but the changing GCC semantics of NONANSI and redeclaration
have resulted in a divergence.

Roger
--



More information about the Gcc-patches mailing list