-
Notifications
You must be signed in to change notification settings - Fork 790
Description
[conv.qual] p3 omitted to specify the result of the conversion, it might be
The pointer value ([basic.compound]) is unchanged by this conversion.
it implies that the result has the same pointer value as the original.
admit only two similar types can undergo qualification conversion
The current wording just says
A prvalue of type T1 can be converted to type T2 if the qualification-combined type of T1 and T2 is T2.
According to the definition of qualification-combined type, it just concerns whether the corresponding Pi and CVi satisfy some conditions. For example: int **
and char**
.
#4860 has excluded an identity conversion from qualification conversion. But two types that have a difference only in their top-level cv-qualifications are also considered to be different types. For example:
int const
vs. int
, char* const
vs. char*
, they only differ in their top-level cv-qualifiers.
So, based on that, the wording might be changed to
A prvalue of type T1 can be converted to another type T2(ignoring cv-qualification) if T1 and T2 are similar and the qualification-combined type of T1 and T2 is T2.
duplicately add const
[conv.qual] p3.3 says
if the resulting cv3i is different from cv1i or cv2i or the resulting P3i is different from P1i or P2i, then const is added to every cv3k for 0< k < i
Consider a const has added in cv3k due to [conv.qual] p3.1. [conv.qual] p3.3 can result in a duplicate addition. For example:
T1 = int***
and T2 = int *const* const*
, after applying [conv.qual] p3.1, T3 will be pointer to const pointer to const pointer to int
where cv32 is different from cv12, however, cv31 does have a const
. {const const }
is not a valid set defined in [basic.type.qualifier] p6.
The change might be
if the resulting cv3i is different from cv1i or cv2i or the resulting P3i is different from P1i or P2i, then const is added to every cv3k for 0< k < i if cv3k haven't yet comprised a
const
[conv.qual] p3 should apply to a pointer, a pointer to member types
Because the bullets in p3 refer to the component Pi
that is defined as “pointer to”, “pointer to member of class Ci of type”, “array of Ni”, “array of unknown bound of”. So, the precondition for this definition should be n
≥ 1
The initial sentence might be changed to
The qualification-combined type of two types T1 and T2 is the type T3 similar to T1 whose qualification-decomposition(where n ≥ 1 ) is such that:
As a similar reason to the above, the definition of similar might be changed to
Two types T1 and T2 are similar if they have qualification-decompositions with the same n such that either there is no Pi component, or the corresponding Pi components are either the same or one is “array of Ni” and the other is “array of unknown bound of”, and the types denoted by U are the same.