cplusplus / cplusplus/draft

[conv.qual] Improvement and supply the omitted result

Open
#5,358 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

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

https://github.com/cplusplus/draft/pull/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.

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 by reading [conv.qual], especially paragraph 3, together with [basic.compound] and [basic.type.qualifier], then check the definitions of qualification-combined and similar types cited in the issue. Done means reaching and documenting an agreed wording for the omitted result, similar-type restriction, duplicate const handling, and pointer or pointer-to-member precondition.

Written by the indexing model from the issue text.

Assessment

Tech stack
tex
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.