You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CWG2879 [expr.const.cast] p3 does not cover all cases of similar types #232
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[expr.const.cast] p3 says:
For two similar types T1 and T2, a prvalue of type T1 may be explicitly converted to the type T2 using a const_cast if, considering the qualification-decompositions of both types, each P1i is the same as P2i for all i. The result of a const_cast refers to the original entity.
invalid use of 'const_cast' with type 'int', which is not a pointer, reference, nor a pointer-to-data-member type
However, we do not have this limitation in subclause [expr.const.cast] p3. Moreover, each P1i is the same as P2i for all i can just be vacuous true if Pi is empty.
[expr.const.cast] p2 also implies the case
Subject to the restrictions in this subclause, an expression can be cast to its own type using a const_cast operator.
changed the title [-][expr.const.cast] p3 does not cover all cases of similar types[/-][+]CWG2879 [expr.const.cast] p3 does not cover all cases of similar types[/+]on Apr 16, 2024
Activity
frederick-vs-ja commentedon Mar 20, 2023
There's implementation divergence on
nullptr_t.MSVC accepts identically converting cases, while GCC and Clang reject them.
Presumably, the intent is restricting the types to object pointer types (including cv
void*), object reference types, and pointer-to-data-member types.frederick-vs-ja commentedon Apr 16, 2024
Addressed by CWG2879.
[-][expr.const.cast] p3 does not cover all cases of similar types[/-][+]CWG2879 [expr.const.cast] p3 does not cover all cases of similar types[/+]