This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-27
(From submission #659.)
Consider:
template <auto> constexpr bool B = true; template <unsigned X0> concept C = B<X0>; template <unsigned short X1> concept C2 = C<X1>; template <unsigned X> void f() requires C<X>; // #1 template <unsigned X> int f() requires C2<X> && true; // #2 void g() { return f<65536>(); // should probably call #1 } void h() { f<0>(); // ambiguous? }
The rules in 13.5.4 [temp.constr.normal] bullet 1.4 do not specify how the type of the non-type template parameter X1 in the definition of concept C2 affects the parameter mapping. There is implementation divergence: gcc and MSVC reject the call in g and accept the call in h, resolving to #2 in both cases. Clang and EDG accept the call in g (resolving to #1) and reject the call in h as ambiguous.
As a suggested resolution, introduce a shadow constraint that checks the validity of the template argument for the concept's template parameter when normalizing the use of C2 from #2. This would reject the call to #2 from g (choosing #1) and select #2 as more constrained for the call from h.