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] p2 The meaning of "its own type" is not clear #5509

Open
xmh0511 opened this issue Jun 7, 2022 · 2 comments
Open

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jun 7, 2022

[expr.reinterpret.cast] p2 says

An expression of integral, enumeration, pointer, or pointer-to-member type can be explicitly converted to its own type; such a cast yields the value of its operand.

What does "its own type" mean? Does it mean the identical original type or something else? Consider this example:

reinterpret_cast<int>(10);
reinterpret_cast<int const>(10);
reinterpret_cast<int volatile>(10);
reinterpret_cast<int const volatile>(10);

Both GCC and Clang accept this example. I think such a conversion is intended to be regulated by [expr.reinterpret.cast] p2. Because p1 says

Conversions that can be performed explicitly using reinterpret_­cast are listed below. No other conversion can be performed explicitly using reinterpret_­cast.

Except that p2 might be relevant to this example, all other rules are irrelevant to the above example. It is necessary to clarify what "its own type" means. Presumably, it means

An expression of integral, enumeration, pointer, or pointer-to-member type can be explicitly converted to the cv-unqualified version or cv-qualification of that type.

@JohelEGP
Copy link
Contributor

JohelEGP commented Jun 7, 2022

How about

An expression of type T, where T is an integral, enumeration, pointer, or pointer-to-member type, can be explicitly converted to cv T.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jun 7, 2022

How about

An expression of type T, where T is an integral, enumeration, pointer, or pointer-to-member type, can be explicitly converted to cv T.

Looks good and is concise.

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

2 participants