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] CWG 2365: Incorrect wording regarding dynamic_cast #1453

Closed
introom opened this issue Feb 9, 2017 · 4 comments
Closed
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@introom
Copy link

introom commented Feb 9, 2017

In paragraph 4, http://eel.is/c++draft/expr.dynamic.cast#4

If the value of v is a null pointer value in the pointer case, the result is the null pointer value of type T.

And in paragraph6,

Otherwise, v shall be a pointer to or a glvalue of a polymorphic type.

So the otherwise means the v in p4 doesn't have to be polymorphic.

However, this is not possible because the compiler can only check if "v" is a null pointer at runtime. If "v" is not a null pointer, and unluckily has no RTTI, then the runtime could do nothing meaningufl, ill-formed?

BTW, Clang and GCC requires the "v" in p4 to be of pointer to polymorphic type.

@cpplearner
Copy link
Contributor

Do you mean this:

struct T1 {};
struct T2 {};
T1* p = nullptr;
dynamic_cast<T2*>(p);

This appears to be valid according to p4, but will not be valid if p is not a null pointer.

@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Feb 9, 2017
@jensmaurer
Copy link
Member

This does not seem to be editorial; the normative wording is nonsensical here. Submitted as a CWG issue: http://lists.isocpp.org/core/2017/02/1733.php .

@jensmaurer jensmaurer changed the title Incorrect wording regarding dynamic_cast [expr.dynamic.cast] Incorrect wording regarding dynamic_cast Feb 9, 2017
@jensmaurer
Copy link
Member

CWG in Jacksonville: treat as a core issue

@jensmaurer jensmaurer added the not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. label Mar 24, 2018
@jensmaurer jensmaurer changed the title [expr.dynamic.cast] Incorrect wording regarding dynamic_cast [expr.dynamic.cast] CWG 2365: Incorrect wording regarding dynamic_cast Nov 8, 2018
@jensmaurer
Copy link
Member

Resolved with commit e81049e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

No branches or pull requests

3 participants