https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120259
Bug ID: 120259 Summary: Using Incomplete&& as argument in invoke_r/move_only_function fails to compile Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: tkaminsk at gcc dot gnu.org Target Milestone: --- Passing rvalue reference to incomplete type or instantiating move_only_function with it as parameter produces ill-formed program. ``` struct Incomplete; int foo(Incomplete& i); void bar(Incomplete& i) { std::invoke_r<int>(&foo, std::move(i)); // ILL-FORMED std::move_only_function<int(Incomplete&&)> mo(&foo); // ILL-FORMED } ``` See: https://godbolt.org/z/GvW7veGKa The error produced is: /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/type_traits:3055:53: error: static assertion failed: each argument type must be a complete class or an unbounded array 3055 | static_assert((std::__is_complete_or_unbounded( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 3056 | __type_identity<_ArgTypes>{}) && ...), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The failure in `move_only_function` is due instantiation of std::invoke_r.