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

Open
introom opened this Issue Feb 9, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@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

This comment has been minimized.

Copy link
Contributor

cpplearner commented Feb 9, 2017

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 label Feb 9, 2017

@jensmaurer

This comment has been minimized.

Copy link
Contributor

jensmaurer commented Feb 9, 2017

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

This comment has been minimized.

Copy link
Contributor

jensmaurer commented Mar 15, 2018

CWG in Jacksonville: treat as a core issue

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment