https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101236
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |101239 --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- I tried this workaround in unique_ptr so that the undefined LLVM code would "work" as before: --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -491,6 +491,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = __and_< is_base_of<_Tp, _Up>, __not_<is_same<__remove_cv<_Tp>, __remove_cv<_Up>>> >; + template<typename _Ptr> + static constexpr auto + _S_nothrow_deref(_Ptr __p = _Ptr(), size_t __n = 0) + -> decltype(noexcept(__p[__n])) + { return noexcept(__p[__n]); } + + template<typename _Ptr> + static constexpr bool + _S_nothrow_deref(...) + { return noexcept(__p[__n]); } + public: using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; using element_type = _Tp; @@ -654,8 +665,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Access an element of owned array. typename std::add_lvalue_reference<element_type>::type - operator[](size_t __i) const - noexcept(noexcept(std::declval<pointer>()[std::declval<size_t&>()])) + operator[](size_t __i) const noexcept(_S_nothrow_deref<pointer>()) { __glibcxx_assert(get() != pointer()); return get()[__i]; But this gets an ICE, see PR 101239 Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101239 [Bug 101239] "Internal compiler error: Error reporting routines re-entered." in size_in_bytes_loc