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

--- Comment #5 from Boris Staletic <boris.staletic at protonmail dot com> ---
After a bit more playing, a valid way to get a reflection of a pointer to
member's type is:

    type_of(reflect_constant(&[:^^T::member:]))

Alternatively, one might try to assemble the type manually, such as

    constexpr auto member = ^^T::member;
    costexpr auto [...args_t] = [: reflect_static_array( parameters_of(
type_of(member) ) | views::drop(1) ) :];
    using type = typename
[:return_type_of(member):](T::*)(typename[:args_t:]...);

However, at one point, the latter approach did get gcc to ICE in the same way
as in the opening test case.

Either way and perhaps surprisingly to users, this does not produce the type of
pointer to member:

    constexpr auto member = ^^T::member; // Suppose int T::member(int);
    constexpr auto type = type_of(member); // Actually int(T*, int)
    constexpr auto ptr = add_pointer(type); // Actually int(*)(T*, int)

Therefore the original test case is now correctly rejected.

Reply via email to