[PATCH] D113517: Correct handling of the 'throw()' exception specifier in C++17.

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 10 07:33:52 PST 2021

jyknight added a comment.

In D113517#3120030 <https://reviews.llvm.org/D113517#3120030>, @rsmith wrote:

> What's the motivation for this change? I believe the current behavior is still conforming: `set_unexpected` is no longer (officially) part of the standard library (though it still exists as a zombie name), and the default `unexpected` handler calls `terminate`, so calling `unexpected` rather than `terminate` should have the same effect, except in non-conforming programs that call `std::set_unexpected` anyway (and for such programs, calling `unexpected` seems like the behavior the programmer would expect). Do we generate better code if we call `terminate` rather than `unexpected`?

Today: no, we don't.

But, I'm planning to propose further changes to improve noexcept codegen in Clang -- which is currently quite bad, compared to what it should be, because it's effectively following the same rules as legacy throw(). This change allows those future optimizations to apply to throw() as well, in C++17 mode, which is the desirable outcome.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list