Skip to content

Mislead utterance of section [expr.mptr.oper] #4703

Open
@xmh0511

Description

@xmh0511
Contributor

The binary operator .* binds its second operand, which shall be of type “pointer to member of T” to its first operand, which shall be a glvalue of class T or of a class of which T is an unambiguous and accessible base class. The result is an object or a function of the type specified by the second operand.

As aforementioned, the second operand has the type of “pointer to member of T”, but the rule says the result is an object or a function of the type specified by the second operand, Is it a contradiction here?

Maybe we should say

The result is an object or a function of the type specified by the entity to which the second operand refers.

Can E2 be the second operand of the class member access operator?

Abbreviating pm-expression.*cast-expression as E1.*E2, E1 is called the object expression. If the dynamic type of E1 does not contain the member to which E2 refers, the behavior is undefined. Otherwise, the expression E1 is sequenced before the expression E2.

The restrictions on cv-qualification, and the manner in which the cv-qualifiers of the operands are combined to produce the cv-qualifiers of the result, are the same as the rules for E1.E2 given in [expr.ref].

Again, E2 still has the type of “pointer to member of T” in the context of the above rule, which means E2 is invalid to be the second operand of the expression E1.E2.

Activity

jwakely

jwakely commented on Jun 17, 2021

@jwakely
Member

As aforementioned, the second operand has the type of “pointer to member of T”, but the rule says the result is an object or a function of the type specified by the second operand, Is it a contradiction here?

No. The type specified by the second operand does not mean the type of the second operand.

A pointer to member of type int T::* specifies a result of type int. A pointer to member of type void (T::*)(char) specifies a result of type void(char).

which means E2 is invalid to be the second operand of the expression E1.E2

Yes, that one seems wrong.

xmh0511

xmh0511 commented on Jun 17, 2021

@xmh0511
ContributorAuthor

As aforementioned, the second operand has the type of “pointer to member of T”, but the rule says the result is an object or a function of the type specified by the second operand, Is it a contradiction here?

No. The type specified by the second operand does not mean the type of the second operand.

A pointer to member of type int T::* specifies a result of type int. A pointer to member of type void (T::*)(char) specifies a result of type void(char).

Please ask which is the normative rule in the standard gives that meaning?

jwakely

jwakely commented on Jun 17, 2021

@jwakely
Member

There isn't a rule saying "the type specified by" means "the same type" either, not in the standard and not in English.

xmh0511

xmh0511 commented on Jun 17, 2021

@xmh0511
ContributorAuthor

There isn't a rule saying "the type specified by" means "the same type" either, not in the standard and not in English.

Yes, that is what I'm concerning here. The phrase "the type specified by" gives an ambiguous meaning, we can read it in either meaning. So, I think we should replace it with more clear wording to avoid the potential misunderstanding.

jwakely

jwakely commented on Jun 17, 2021

@jwakely
Member

If you choose to read the words a certain way, and that creates a contradiction or nonsensical meaning, maybe you shouldn't read them that way.

xmh0511

xmh0511 commented on Jun 17, 2021

@xmh0511
ContributorAuthor

If you choose to read the words a certain way, and that creates a contradiction or nonsensical meaning, maybe you shouldn't read them that way.

Agree with you. But I think we could improve the wording to make it to be more readable. After all, in the other place, such as "T&", we use the utterance "the referenced type" or "the type to which the reference refers" and so on. Have a similar way for pointer type. Why not use a similar tone here instead use the "the type specified by..."?

self-assigned this
on Jul 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @jwakely@xmh0511@jensmaurer

    Issue actions

      Mislead utterance of section [expr.mptr.oper] · Issue #4703 · cplusplus/draft