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

2024-03-20


1417. Pointers/references to functions with cv-qualifiers or ref-qualifier

Section: 9.3.4.6  [dcl.fct]     Status: C++14     Submitter: Daniel Krügler     Date: 2011-11-17

[Moved to DR at the September, 2013 meeting.]

It is not sufficiently clear from the existing wording that pointers and references to function types containing cv-qualifiers or a ref-qualifier are not permitted and thus would result in a deduction failure if created during template argument substitution. Normative wording to that effect should be added to, e.g., 9.3.4.6 [dcl.fct].

Proposed resolution (October, 2012) [SUPERSEDED]:

  1. Change 9.3.4.2 [dcl.ptr] paragraph 4 as follows:

  2. [Note: There are no pointers to references Forming a pointer to reference type is ill-formed; see 9.3.4.3 [dcl.ref]. Forming a pointer to a function type that has cv-qualifiers or a ref-qualifier is ill-formed; see 9.3.4.6 [dcl.fct]. Since the address of a bit-field (11.4.10 [class.bit]) cannot be taken, a pointer can never point to a bit-field. —end note]
  3. Change 9.3.4.3 [dcl.ref] paragraph 6 as follows:

  4. If a typedef typedef-name (9.2.4 [dcl.typedef]), a type template-parameter (13.4.2 [temp.arg.type]), 13.2 [temp.param]) or a decltype-specifier (9.2.9.3 [dcl.type.simple]) denotes a type TR that is a reference to a type T, an attempt to create...
  5. Add the following as a new paragraph at the end of 9.3.4.3 [dcl.ref]:

  6. [Note: Forming a reference to a function type that has cv-qualifiers or a ref-qualifier is ill-formed; see 9.3.4.6 [dcl.fct]. —end note]
  7. Change 9.3.4.6 [dcl.fct] paragraph 6 as follows:

  8. A function type with a cv-qualifier-seq or a ref-qualifier (including by typedef-name (9.2.4 [dcl.typedef], 13.2 [temp.param]) or decltype-specifier (9.2.9.3 [dcl.type.simple])) shall only be part of appear as:

    [Example:

       typedef int FIC(int) const;
       FIC f;       // ill-formed: does not declare a member function
       struct S {
        FIC f;      // OK
       };
       FIC S::*pm = &S::f; // OK
    

    end example]

    The effect of a cv-qualifier-seq in a function declarator...

  9. Delete the following text from 9.3.4.6 [dcl.fct] paragraph 10 (the example is moved to paragraph 6, as indicated in the preceding change):

  10. A typedef of a function type whose declarator includes a cv-qualifier-seq shall be used only to declare the function type for a non-static member function, to declare the function type to which a pointer to member refers, or to declare the top-level function type of another function typedef declaration. [Example: ... —end example]

Additional note (March, 2013):

The issue is being returned to "review" status out of concern that 12.5 [over.built] paragraph 11 requires forming a reference to a function type that might have a cv-qualifier or ref-qualifier.

Proposed resolution (April, 2013):

  1. Change 9.3.4.2 [dcl.ptr] paragraph 4 as follows:

  2. [Note: There are no pointers to references Forming a pointer to reference type is ill-formed; see 9.3.4.3 [dcl.ref]. Forming a pointer to function type is ill-formed if the function type has cv-qualifiers or a ref-qualifier; see 9.3.4.6 [dcl.fct]. Since the address of a bit-field (11.4.10 [class.bit]) cannot be taken, a pointer can never point to a bit-field. —end note]
  3. Change 9.3.4.3 [dcl.ref] paragraph 6:

  4. If a typedef typedef-name (9.2.4 [dcl.typedef]), a type template-parameter (13.4.2 [temp.arg.type]), 13.2 [temp.param]) or a decltype-specifier (9.2.9.3 [dcl.type.simple]) denotes a type TR that is a reference to a type T, an attempt to create the type “lvalue reference to cv TR” creates the type “lvalue reference to T”, while an attempt to create the type “rvalue reference to cv TR" creates the type TR. [Example:...
  5. Add the following as a new paragraph at the end of 9.3.4.3 [dcl.ref]:

  6. [Note: Forming a reference to function type is ill-formed if the function type has cv-qualifiers or a ref-qualifier; see 9.3.4.6 [dcl.fct]. —end note]
  7. Change 9.3.4.6 [dcl.fct] paragraph 6 as follows:

  8. A function type with a cv-qualifier-seq or a ref-qualifier (including a type named by typedef-name (9.2.4 [dcl.typedef], 13.2 [temp.param])) shall appear only be part of as:

    [Example:

       typedef int FIC(int) const;
       FIC f;              // ill-formed: does not declare a member function
       struct S {
         FIC f;            // OK
       };
       FIC S::*pm = &S::f; // OK
    

    end example] The effect of a cv-qualifier-seq...

  9. Change 9.3.4.6 [dcl.fct] paragraph 10 as follows, moving the example to paragraph 6 as shown above:

  10. ...—end example] A typedef of a function type whose declarator includes a cv-qualifier-seq shall be used only to declare the function type for a non-static member function, to declare the function type to which a pointer to member refers, or to declare the top-level function type of another function typedef declaration. [Example: ... —end example]
  11. Change 12.5 [over.built] paragraph 11 as follows:

  12. For every quintuple (C1, C2, T, CV1, CV2), where C2 is a class type, C1 is the same type as C2 or is a derived class of C2, T is an object type or a function type, and CV1 and CV2 are cv-qualifier-seqs, there exist candidate operator functions of the form

    where CV12 is the union of CV1 and CV2. The return type is shown for exposition only; see 7.6.4 [expr.mptr.oper] for the determination of the operator's result type.