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

[expr.dynamic.cast] Missing case when C is the most derived class in the runtime check #4887

Closed
JohelEGP opened this issue Sep 9, 2021 · 4 comments

Comments

@JohelEGP
Copy link
Contributor

JohelEGP commented Sep 9, 2021

See https://eel.is/c++draft/expr.dynamic.cast#7 and https://eel.is/c++draft/expr.dynamic.cast#8. In the runtime check, C is always the type of a base class subobject of the most derived object. The case when T is the most derived class is not specified.

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 9, 2021

Isn't that case already covered by https://eel.is/c++draft/expr.dynamic.cast#3?

@JohelEGP
Copy link
Contributor Author

JohelEGP commented Sep 9, 2021

Only when "v is the same as T (ignoring cv-qualifications)", which might not be the case if v is a base class subobject of C.

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 10, 2021

I think it is covered by [expr.dynamic.cast#8.1], namely T is the type of the most derived object while the v is a subobject thereof.

If, in the most derived object pointed (referred) to by v, v points (refers) to a public base class subobject of a C object, and if only one object of type C is derived from the subobject pointed (referred) to by v the result points (refers) to that C object.

C may be the type of the most derived object or the one base class subobject of which the v is a subobject.

@JohelEGP
Copy link
Contributor Author

Thank you, that's right.

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