This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: genattrtab speedup 4/4

From: "Geert Bosch" <>

Note that this exactly matches semantics for Ada's pragma Pure, so there
is some precedent for such a pragma. Mathematical functions, such as
root or even simple integer division are pure, but still may not  return
throw an exception or abort. As it is hard to verify that a function
returns (see halting problem), these semantics make a lot of sense to  me.

If someone kindly implements such an attribute (such as pure_noreturn/const_noreturn?) there are a *lot* of functions in GCC that can be tagged as such. (Dig dig dig...) here's the message where I discussed the issue originally in 2002 containing some links from 2000:

I actually had a patch to detect const/pure functions and tell the user
via -Wmissing-const/-Wmissing-pure similar to -Wmissing-noreturn.  It would
also warn about bad declarations to address concerns about functions
changing to impure over time and the programmer not realizing they must
remove the attribute.  (Some messages downthread aren't linked by mailer
reference so sort by subject or you'll miss some replies):

Patch take 2 and more discussion (same problem with thread links):

There's a lot of interesting stuff about noreturn functions in there.  Even
loops can potentially cause a function to be noreturn.  There was some
disagreement about whether to add a new attribute "maynotreturn", or change
the behavior of attribute "pure".  I don't think consensus was achieved as I
never installed my patch.  How we optimize pure/const functions seven years
later may change opinions on how and whether to proceed.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]