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

            Bug ID: 98388
           Summary: Throwing move-only parameter results in hard error in
                    SFINAE context
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ensadc at mailnesia dot com
  Target Milestone: ---

https://godbolt.org/z/xn8fYz

====
struct moveonly {
    moveonly() = default;
    moveonly(moveonly&&) = default;
};

template<class T>
constexpr auto is_throwable(T t) -> decltype(throw t, true) {
    return true;
}
template<class T>
constexpr bool is_throwable(...) { return false; }

constexpr bool b = is_throwable<moveonly>(moveonly{});

====
<source>: In substitution of 'template<class T> constexpr decltype
((<throw-expression>, true)) is_throwable(T) [with T = moveonly]':
<source>:13:43:   required from here
<source>:7:46: error: use of deleted function 'constexpr
moveonly::moveonly(const moveonly&)'
    7 | constexpr auto is_throwable(T t) -> decltype(throw t, true) {
      |                                              ^~~~~~~
<source>:1:8: note: 'constexpr moveonly::moveonly(const moveonly&)' is
implicitly declared as deleted because 'moveonly' declares a move constructor
or move assignment operator
    1 | struct moveonly {
      |        ^~~~~~~~
<source>:7:52: note:   in thrown expression
    7 | constexpr auto is_throwable(T t) -> decltype(throw t, true) {
      |                                                    ^
====

I'm not sure what the value of `b` should be, but I believe that it should not
be a hard error. (Clang and MSVC initialize `b` to `true`.)

Reply via email to