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.reinterpret.cast] Define reinterpret_cast from nullptr_t in terms of reinterpret_cast<void*> rather than c-style cast #1963

Closed
wants to merge 1 commit into from

Conversation

RedBeard0531
Copy link
Contributor

It seems clearer to directly use the specific cast rather than relying on the equivalence of the c-style cast.

…ms of reinterpret_cast<void*> rather than c-style cast

It seems clearer to directly use the specific cast rather than relying on the equivalence of the c-style cast.
@jwakely
Copy link
Member

jwakely commented Mar 19, 2018

Why use reinterpret_cast to get a null pointer of type void* when 0 is already a null pointer constant? i.e. you could use static_cast<void*>(0).

Even so, I think (void*)0 is a clearer way to say "null pointer of type void*".

@timsong-cpp
Copy link
Contributor

This is also wrong. reinterpret_cast<void*>(0) is not guaranteed to give you a null pointer value.

@RedBeard0531
Copy link
Contributor Author

Thanks for correcting me. I thought (void*)0 was doing a reinterpret_cast as it would for any int other than a literal 0. I forgot that literal 0 is magical and results in a "standard pointer conversion" (http://eel.is/c++draft/conv#ptr-1) which doesn't have explicit syntax to designate.

Closing.

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 this pull request may close these issues.

None yet

3 participants