[libcxx-commits] [PATCH] D130283: [libc++] Allow assigning std::rethrow_if_nested() to a function pointer

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 25 10:08:27 PDT 2022


Mordante added a comment.

In D130283#3676514 <https://reviews.llvm.org/D130283#3676514>, @xingxue wrote:

>> Did I overlook something and is `std::rethrow_if_nested` marked as addressable?
>
> Hi @mordante, Thanks for your comments.  I searched the standards and could not find any thing that is marked as `addressable`.

These should be some things marked, IIRC mainly in `<iostream>`.

I can be wrong but my reasoning is that `rethrow_if_nested()` is a global function that has a physical implementation and a physical address. Therefore, it is addressable. The following code snippet and 'nm' output show it has a physical address, noting that the signature of `rethrow_if_nested()` has `__enable_if` etc. as an argument and that is the reason why it does not match the signature defined by the standard, i.e., `void rethrow_if_nested(const E&)`, when assigned to a function pointer. `throw_with_nested()` used to have the same problem but was fixed. This patch takes the same approach as used for `throw_with_nested()`.

True, it's addressable now. But this isn't guaranteed by the Standard, hence the question do we want to guarantee this works with libc++. If we do we probably should document that as an extension. Since this isn't Standard behaviour the test should be moved from `std` to `libcxx` since this might fail on other implementations.

But let's wait and see what @ldionne thinks about adding this guarantee.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130283/new/

https://reviews.llvm.org/D130283



More information about the libcxx-commits mailing list