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

            Bug ID: 119469
           Summary: iter_rvalue_reference_t is wrong for function types
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

#include <type_traits>
#include <iterator>

bool a1() { return std::is_same_v<std::iter_rvalue_reference_t<int(int)>,
int(&)(int)>; }
bool a2() { return std::is_same_v<std::iter_rvalue_reference_t<int(int)>,
int(&&)(int)>; }
bool a3() { return std::is_same_v<std::iter_rvalue_reference_t<int(int)>,
int(int)>; }
bool a4() { return std::is_same_v<std::iter_rvalue_reference_t<int(int)>,
int(*)(int)>; }

template<typename T>
using alt_iter_rvalue_reference_t =
decltype(std::ranges::iter_move(std::declval<T&>()));

bool b1() { return std::is_same_v<alt_iter_rvalue_reference_t<int(int)>,
int(&)(int)>; }
bool b2() { return std::is_same_v<alt_iter_rvalue_reference_t<int(int)>,
int(&&)(int)>; }
bool b3() { return std::is_same_v<alt_iter_rvalue_reference_t<int(int)>,
int(int)>; }
bool b4() { return std::is_same_v<alt_iter_rvalue_reference_t<int(int)>,
int(*)(int)>; }


Expected: Since the spec defines iter_rvalue_reference_t as
decltype(std::ranges::iter_move(std::declval<T&>())), the two sets of functions
should be identical (according to Clang and the MSVC STL head maintainer, the
correct answer is a1/b1)

Actual: a2 and b1 are true (it's a4/b4 on MSVC, due to a compiler bug)

https://godbolt.org/z/bTGbKr3ee

Reply via email to