You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Microsoft mode: qualified call of a function template found through an inline namespace can select a global function #588
In Microsoft permissive mode (which implies --no_dep_name), a namespace-qualified call of a single function template that is found through an inline namespace (or a using-directive) can select a global function of the same name when the call is substituted:
template <classT> T&& declval();
template <classT> structvoid_t_impl { typedefvoid type; };
doublefn(float, double);
namespacelib {
inlinenamespacev1 {
template <classT> T fn(T, T);
}
}
template <classT, classU, class = void>
structcan_call { staticconstbool value = false; };
template <classT, classU>
structcan_call<T, U, typename void_t_impl<decltype(lib::fn(declval<T>(), declval<U>()))>::type> {
staticconstbool value = true;
};
static_assert(!can_call<float, double>::value, "lib::fn(float, double) is not callable");
MSVC (19.37, with or without /permissive-) accepts this, as do EDG's strict, GCC, and Clang modes, but EDG in Microsoft mode reports:
error: static assertion failed with "lib::fn(float, double) is not callable"
Deduction for lib::fn<T> fails (T deduced as both float and double), but ::fn(float, double) is selected instead. The same happens with, e.g., decltype(lib::fn(t, u)) as the return type of a function template: Substitution succeeds and the call in the function body is then rejected.
Initial analysis in this mode shows that the overload set of a non-member function called in a template is looked up again at instantiation to pick up overloads declared after the template. For a qualified name, that should be a lookup in the qualifying namespace, but when the name was found through an inline namespace or a using-directive (so that the saved lookup result is a namespace projection symbol), it appears an unqualified lookup is done instead, and that finds ::fn.
Activity
Qualified call via an inline namespace in Microsoft mode finding a gl…