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

[intro.object]/1: the (interpretation of the) value of an object is determined by the type of the expressions used to access it #2308

Closed
languagelawyer opened this issue Aug 24, 2018 · 5 comments · Fixed by #4490

Comments

@languagelawyer
Copy link
Contributor

languagelawyer commented Aug 24, 2018

[intro.object]/1:

Some objects are polymorphic ([class.virtual]); the implementation generates information associated with each such object that makes it possible to determine that object's type during program execution.
For other objects, the interpretation of the values found therein is determined by the type of the expressions ([expr.compound]) used to access them.

The last sentence doesn't make any sense.
The only way I found to give sense to this sentence is: "object" — "region of storage", "values found therein" — "pile of bits in storage", and this sentence says that when the storage is accessed by an expression, these bits are interpreted as an object representation of an object with the type of an expression.

@languagelawyer
Copy link
Contributor Author

This basically tells that calling non-virtual function through a pointer/reference to a base class will call a method of the base class.
NAD.

@jwakely
Copy link
Member

jwakely commented Aug 28, 2018

Also, typeid(obj) for a non-polymorphic type only depends on the static type of the expression obj.

@languagelawyer
Copy link
Contributor Author

languagelawyer commented Aug 28, 2018

@jwakely I don't think an unevaluated operand expression interprets values of objects, because it doesn't even access them.

@jwakely
Copy link
Member

jwakely commented Aug 28, 2018

And whether that's an unevaluated operand or not depends on whether it's a polymorphic type. The interpretation of obj in that context depends on the static type. The interpretation of dynamic_cast<X&>(obj) can also depend on the static type of obj. When it's a polymorphic type the information associated with the object is used "to determine the object's type during program execution". For other objects, it isn't.

@jensmaurer jensmaurer reopened this Jul 16, 2019
@languagelawyer
Copy link
Contributor Author

Looks like my opinion that this wording is an artifact left from the «object is a region of storage» times is correct. That definition of object and the last sentence of [intro.object]/1 were copied from the C standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants