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

2023-01-15


1298. Incorrect example in overload resolution

Section: 12.2.4.3  [over.ics.rank]     Status: CD3     Submitter: Nikolay Ivchenkov     Date: 2011-04-15

[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]

The following example appears in 12.2.4.3 [over.ics.rank] paragraph 3:

  template<class T> int f(T&);
  template<class T> int f(T&&);
  void g();
  int i1 = f(g); // calls f(T&)

This is not correct. Because of the special deduction rule for rvalue reference parameters in 13.10.3.2 [temp.deduct.call] paragraph 3 and the reference-collapsing rules of 9.3.4.3 [dcl.ref] paragraph 6, the parameter type for both will be void(&)().

Proposed resolution (August, 2011):

Change the example in 12.2.4.3 [over.ics.rank] paragraph 3 bullet 1 sub-bullet 5 as follows:

  template<class T> int f(T&);
  template<class T> int f(T&&);
  int f(void(&)());     // #1
  int f(void(&&)());    // #2
  void g();
  int i1 = f(g);        // calls f(T&) #1