Skip to content

CWG2902 Use of id-expressions denoting explicit object member functions is too permissive #573

@brevzin

Description

@brevzin

Full name of submitter (unless configured in github; will be published with the issue): Barry Revzin

Reference (section label): Unknown

Link to reflector thread (if any): None

Issue description: There is implementation divergence in the following example:

struct C {
    int f(this C);
};

using T = decltype(C::f); // #1
int g = C::f(42); // #2

For #1, MSVC currently accepts, gcc reject and clang reject. Our current wording, I think, allows this by way of the P2797's change to [expr.prim.id.general]'s limits of when to use an id-expression that denotes a non-static member or non-static member function to only apply to implicit object member functions. However, that change doesn't seem related to the rest of the paper and the design intent of P0847 was to reject such usage.

For #2, all compilers current reject, but I think the [expr.prim.id.general] relaxation might actually allow it. I'm not sure if there is any other rule that forbids it, but we do want to disallow this case.

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