cplusplus / cplusplus/draft

[expr.reinterpret.cast] p2 The meaning of "its own type" is not clear

Open
#5,509 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with [expr.reinterpret.cast] p1-p2 and the examples in the issue. Determine whether “its own type” includes cv-qualified and cv-unqualified forms, then revise the wording to make the intended conversion rule explicit. Done means the examples and the surrounding restriction on reinterpret_cast conversions are unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.