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

2024-04-18


2564. Conversion to function pointer with an explicit object parameter

Section: 12.2.2.2.3  [over.call.object]     Status: drafting     Submitter: Christof Meerwald     Date: 2022-04-11

Subclause 12.2.2.2.3 [over.call.object] paragraph 2 considers only those conversion funtions matching a particular grammar pattern. This unintendedly excludes conversion functions with an explicit object parameter (and, as a pre-existing defect, noexcept conversion functions):

In addition, for each non-explicit conversion function declared in T of the form
operator conversion-type-id ( ) cv-qualifier-seqopt ref-qualifieropt noexcept-specifieropt attribute-specifier-seqopt ;
where the optional cv-qualifier-seq is the same cv-qualification as, or a greater cv-qualification than, cv, and where conversion-type-id denotes the type “pointer to function of (P1 , . . . , Pn ) returning R”, or the type “reference to pointer to function of (P1 , . . . , Pn ) returning R”, or the type “reference to function of (P1 , . . . , Pn ) returning R”, a surrogate call function with the unique name call-function and having the form
R call-function ( conversion-type-id F, P1 a1 , ... , Pn an ) { return F (a1 , . . . , an ); }
is also considered as a candidate function. Similarly, surrogate call functions are added to the set of candidate functions for each non-explicit conversion function declared in a base class of T provided the function is not hidden within T by another intervening declaration. [ Footnote: ...]

For example, there is implementation divergence in handling this example:

  using fn_t = void();
  struct C {
    operator fn_t * (this C const &);
  };

  void foo(C c) {
    c();
  }