This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-03-08


2998. Missing deduction consistency check for partial ordering

Section: 13.10.3.5  [temp.deduct.partial]     Status: open     Submitter: Richard Smith     Date: 2025-03-02

Consider issue 2160, first part:

   template <typename T> void foo(T, T); // (1)
   template <typename T, typename U> void foo(T, U); // (2)

Partial ordering is describing as pairwise (but otherwise independent) P/A matching, missing a check that the deduced values for the various Ps must be consistent per 13.10.3.6 [temp.deduct.type] paragraph 2.

Possible resolution:

Change in 13.10.3.5 [temp.deduct.partial] paragraph 8 as follows:

Using the set of pairs formed from the corresponding resulting types P and A, the deduction is then done as described in 13.10.3.6 [temp.deduct.type]. If P is a function parameter pack, the type A of each remaining parameter type of the argument template is compared with the type P of the declarator-id of the function parameter pack. Each comparison deduces template arguments for subsequent positions in the template parameter packs expanded by the function parameter pack. Similarly, if A was transformed from a function parameter pack, it is compared with each remaining parameter type of the parameter template. If deduction succeeds for a given type, the type from the argument template is considered to be at least as specialized as the type from the parameter template.