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

            Bug ID: 68139
           Summary: rethrow_if_nested should tolerate overloaded unary
                    operator&
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

Test case:

#include <exception>
struct C {
    virtual ~C(){}
    void operator&() const = delete;
};

int main() { std::rethrow_if_nested(C()); }

This results in:

In file included from /usr/local/gcc-head/include/c++/6.0.0/exception:169:0,
                 from prog.cc:1:
/usr/local/gcc-head/include/c++/6.0.0/bits/nested_exception.h: In instantiation
of 'static void std::_Rethrow_if_nested_impl<_Tp, <anonymous>
>::_S_rethrow(const _Tp&) [with _Tp = C; bool <anonymous> = true]':
/usr/local/gcc-head/include/c++/6.0.0/bits/nested_exception.h:161:47:  
required from 'void std::rethrow_if_nested(const _Ex&) [with _Ex = C]'
prog.cc:7:40:   required from here
/usr/local/gcc-head/include/c++/6.0.0/bits/nested_exception.h:145:56: error:
use of deleted function 'void C::operator&() const'
  if (auto __tp = dynamic_cast<const nested_exception*>(&__t))
                                                        ^
prog.cc:4:10: note: declared here
     void operator&() const = delete;

I don't see anything in the standard saying that the type passed to
rethrow_if_nested cannot overload unary &, so the implementation should use
std::addressof or equivalent.

Reply via email to