Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
brevzin opened this issue Jul 12, 2024 · 4 comments

Comments

@brevzin
Copy link

brevzin commented Jul 12, 2024

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.

@ranaanoop
Copy link

ranaanoop commented Jul 13, 2024

@jensmaurer
Copy link
Member

CWG2902 is rewriting that particular section of [expr.prim.id.general]. Looks like the case "naming an explicit object member function" (outside of a class member access or unary & or the implicit-this transformation) should just be ill-formed.

@brevzin , what do you think?

@brevzin
Copy link
Author

brevzin commented Jul 29, 2024

Looks like the case "naming an explicit object member function" (outside of a class member access or unary & or the implicit-this transformation) should just be ill-formed.

Yeah that was our intent with the design/wording. Both #1 and #2 above should be ill-formed. This is part of why we wanted to call an explicit object member function a non-static member function.

@jensmaurer
Copy link
Member

Folded into CWG2902.

@jensmaurer jensmaurer changed the title Use of id-expressions denoting explicit object member functions is too permissive CWG2902 Use of id-expressions denoting explicit object member functions is too permissive Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants