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] cv-qualification cleanups #1934

Closed
zygoloid opened this issue Feb 19, 2018 · 1 comment · Fixed by #1936
Closed

[expr.dynamic.cast] cv-qualification cleanups #1934

zygoloid opened this issue Feb 19, 2018 · 1 comment · Fixed by #1936
Assignees

Comments

@zygoloid
Copy link
Member

[expr.dynamic.cast]p1 says "The dynamic_cast operator shall not cast away constness." That makes some of the later wording redundant. Particulary p5:

"In both the pointer and reference cases, the program is ill-formed if cv2 has greater cv-qualification than cv1 or if B is an inaccessible or ambiguous base class of D."

(The "greater cv-qualification" part is pointless, and suggests incorrectly that this condition does not apply in the other cases in scope in this section.)

Also, p3 need not repeat the "same or more cv-qualification" part (which again has incorrect implications, in this case that we'd perform a runtime check if the cv-qualifications are incompatible).

While here, the p4 wording does not fit the pattern of this section (which is that you bail out early once you hit a matching paragraph). It incorrectly suggests that:

struct A { virtual ~A(); };
struct B : A {};
struct C : A, B {};
C *p = 0;
A *q = dynamic_cast<A*>(p);

... would be valid and produce a null pointer, because we never reach the "inaccessible or ambiguous" wording in p5.

@jensmaurer
Copy link
Member

The latter part is covered by #1453.

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

Successfully merging a pull request may close this issue.

2 participants