Title
Pointers/references to functions with cv-qualifiers or ref-qualifier
Status
c++14
Section
9.3.4.6 [dcl.fct]
Submitter
Daniel Krügler

Created on 2011-11-17.00:00:00 last changed 81 months ago

Messages

Date: 2013-09-15.00:00:00

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

Date: 2013-04-15.00:00:00

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:

    • the function type for a non-static member function,

    • the function type to which a pointer to member refers,

    • the top-level function type of a function typedef declaration or alias-declaration,

    • the type-id in the default argument of a type-parameter (13.2 [temp.param]), or

    • the type-id of a template-argument for a type-parameter (13.3 [temp.names] 13.4.2 [temp.arg.type]).

    [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

      CV12 T& operator->*(CV1 C1*, CV2 T C2::*);

    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.

Date: 2013-03-15.00:00:00

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.

Date: 2012-10-15.00:00:00

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:

    • ...

    • the type-id of a template-argument for a type-parameter (13.3 [temp.names] 13.4.2 [temp.arg.type]).

    [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]
Date: 2011-11-17.00:00:00

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].

History
Date User Action Args
2014-11-24 00:00:00adminsetstatus: drwp -> c++14
2014-03-03 00:00:00adminsetstatus: dr -> drwp
2013-10-14 00:00:00adminsetmessages: + msg4688
2013-10-14 00:00:00adminsetstatus: ready -> dr
2013-05-03 00:00:00adminsetmessages: + msg4311
2013-05-03 00:00:00adminsetstatus: review -> ready
2013-03-18 00:00:00adminsetmessages: + msg4251
2013-03-18 00:00:00adminsetstatus: ready -> review
2012-02-27 00:00:00adminsetmessages: + msg3721
2012-02-27 00:00:00adminsetstatus: open -> ready
2011-11-17 00:00:00admincreate