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

            Bug ID: 91243
           Summary: is_invocable mishandles functions returning
                    indestructible types by value
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

#include <type_traits>

struct S { friend struct F; protected: ~S(); };
struct F { S operator()() { return {}; } };

static_assert(!std::is_invocable_v<F>); // fires

The condition for is_invocable is

> The expression INVOKE(declval<Fn>(), declval<ArgTypes>()...) is well-formed
> when treated as an unevaluated operand

This expression is not well-formed when treated as a normal unevaluated
operand. It's only well-formed when it's the operand of decltype, due to the
special rule in [dcl.type.decltype]p2.

libc++ hard errors for this case. MSVC accepts the snippet above.

Reply via email to