[Bug libstdc++/23888] should debug mode throw instead of assert?

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Oct 3 15:41:00 GMT 2016


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Sylvain Pion from comment #5)
> What about providing both modes, with for example a global run-time flag to
> select the mode which is the most appropriate ?  And maybe defaulting to
> assert, since it looks like users might prefer this (?).

That just seems like unnecessary complexity.

I'm going to close this. I don't find the benefits of this change compelling.


> Also, a side note : throwing an uncaught exception does not seem to destroy
> the stack,

It does if it is caught and rethrown:

void f() { throw 1; }

int main() {
  try {
    f();
  } catch (...) {
    throw;
  }
}

The context of the original throw is lost.

Also, the prevalence of 'noexcept' in the std::lib in modern C++ makes it more
likely that an exception will terminate, so we'd just abort() again anyway.


More information about the Gcc-bugs mailing list