Open xmh0511 opened 1 year ago
I think we want to retain the property that qualification-combined type is a unique type, and handle differences in top-level cv-qualification (which generally don't matter) elsewhere. I do appreciate that the definition of qualification-combined type doesn't define cv_0 of the combined type.
we want to retain the property that qualification-combined type is a unique type ... (which generally don't matter) elsewhere
The defined type may matter when we define casts away constness([expr.const.cast] p7) if we only admit only one type.
int* ptr = 0;
static_cast<int const* const>(ptr); // #1
static_cast<int const*>(ptr); // #2
If we only admit a unique type, then either #1
or #2
will be considered as cast away constness.
Perhaps we can drop top-level cv-qualifiers of scalar types in explicit cast operators before further processing (currently, the top-level cv-qualifiers seem to be dropped after casting). If so, the target types of #1
and #2
are both int const*
.
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[conv.qual] p3 says:
Consider this case:
According to the definition of qualification-combined type,
T3
can beint const*
, which is exactly the same asT2
, andint const* const
, which is merely similar toT2
. Both are similar toT1
. However, "is" implies that the qualification-combined type ofT1
andT2
must be onlyT2
. In this case, if we consider the qualification-combined type asint const* const
, which totally obeys the definition, however, it is notT2
.Suggested Resolution
The qualification-combined type of
T1
andT2
can have more than one possible types(specifically, only have two?), we may say