Skip to content

CWG3166 [expr.reflect] Clarify whether the protected access rule for a pointer-to-member applies to a reflect-expression #852

Description

@t3nsor

Full name of submitter: Aurelien Cassagnes

Issue description: It is not clear whether the following is valid:

class A {
protected:
  void f();
};

struct B : A {
    static constexpr auto r = ^^A::f;
};

According to [expr.reflect]/7.2, "overload resolution for the expression" &A::f "with no target shall select a unique function". Do the restrictions in [class.protected] on the use of the expression &A::f apply to the reflect-expression?

Suggested resolution (by Brian): Edit [expr.reflect]/7.2 as follows:

Otherwise, if the id-expression denotes an overload set S, overload resolution for the expression &S with no target shall select a unique function ([over.over])the expression & id-expression shall be well-formed when considered as an unevaluated operand; R represents that the function selected by overload resolution ([over.over]).

Activity

  1. jensmaurer commented on Mar 11, 2026

    @jensmaurer
    Member
  2. changed the title [-][expr.reflect] Clarify whether the protected access rule for a pointer-to-member applies to a reflect-expression[/-] [+]CWG3166 [expr.reflect] Clarify whether the protected access rule for a pointer-to-member applies to a reflect-expression[/+] on Mar 11, 2026
  3. timsong-cpp commented on Mar 11, 2026

    @timsong-cpp

    Does that wording block taking a reflection of a deleted function?

  4. t3nsor commented on Mar 11, 2026

    @t3nsor
    Author

    Yeah, I guess it does. I forgot that we had a special rule to support that.

  5. t3nsor commented on May 12, 2026

    @t3nsor
    Author

    Following up on the discussion from the most recent telecon.

    We should change [expr.reflect]/7.2 to avoid referring to overload resolution, because the process of resolving the "address of an overload set" as specified in [over.over] is, technically, not a form of overload resolution. See [over.match.general].

    Originally, I thought the choice was between changing [expr.reflect] and [class.protected]. But the former needs changes no matter what wording strategy we choose, so I continue to think that we shouldn't edit [class.protected]. We should just make it clear that the deletedness check doesn't apply. Here's the updated edit for [expr.reflect]/7.2:

    Otherwise, if the id-expression denotes an overload set S, overload resolution for the expression &S with no target shall select a unique function ([over.over])the expression & id-expression shall be well-formed when considered as an unevaluated operand, except that the function F selected as described in [over.over] may be deleted ([dcl.fct.def.delete]); R represents that F.

  6. jensmaurer commented on May 14, 2026

    @jensmaurer
    Member

    Updated: CWG3166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions