https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112874
Bug ID: 112874
Summary: low quality diagnostic for overload resolution failure
when taking address of overloaded function
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: waffl3x at protonmail dot com
Target Milestone: ---
template<typename T> inline constexpr bool not_int_v = !__is_same (T, int);
template<typename T> concept NotInt = not_int_v<T>;
template<bool> struct enable_if {};
template<> struct enable_if<true> { using type = decltype(nullptr); };
template<bool B> using enable_if_t = typename enable_if<B>::type;
template<NotInt T>
void using_concepts(T) {}
template<typename T, enable_if_t<not_int_v<T>> = nullptr>
void using_enable_if(T) {}
void test()
{
// bad diagnostics
void (*fp_concepts)(int) = &using_concepts;
void (*fp_enable_if)(int) = &using_enable_if;
// good diagnostics
using_concepts(0);
using_enable_if(0);
}
In short, the problem is that resolve_address_of_overloaded_function
uses print_candidates instead of the (slightly?) more modern
print_z_candidates. I wont go into too much detail as I'm not super
confident I have it right, but it seems to me that the crux of the
issue is that print_candidates does not call back into
fn_type_unification with the tf_error bit set in complain, while
print_z_candidates does. To be more exact, print_candidates does not
call back into fn_type_unification at all.
In my opinion, print_candidates should be decommissioned and replaced
with print_z_candidates. I don't know what the process of building up a
z_candidate is so I don't know if that is actually practical, but
unifying the interface here would probably be ideal.