https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86286

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> Isn't noexcept mapped to nothrow currently?

The case I'm concerned about is this (I forgot to add it to the original
submission, sorry):

int g (int i);
int goo (int i) noexcept { return g (i); }

The function 'g' doesn't have noexcept or nothrow. Because 'goo' does have
noexcept, it needs to handle any exceptions and call std::terminate (the
must-not-throw EH region).


> Don't you want a "elide-mnt-check" attribute on the caller instead?
> That is, we wrap all noexcept function bodies with a must-not-throw EH
> region and you want to elide that, no?

Yes.  I want to elide the extra code from 'goo', without needing the wrapper
like:

inline int g2 (int i) __attribute__((always_inline,nothrow));
inline int g2 (int i) { return g(i); }
int good (int i) noexcept { return g2 (i); }


or the lambda like:

int good (int i) noexcept {
  return [&]() __attribute__((nothrow)) { return g (i); }();
}


A new attribute could be used for that. My original thought was that reusing
__attribute__((nothrow)) somehow could work too. Maybe it's not a good idea as
a function attribute though, if the function is already marked nothrow because
it's noexcept.

So maybe a statement attribute as the first statement in a function could be
interpreted as elide-mnt-check:

int good (int i) noexcept { 
  __attribute__((nothrow));
  return g2 (i);
}

Reply via email to