Full name of submitter (unless configured in github; will be published with the issue): Jay Ghiron
Reference (section label): [expr.add]/2
Issue description:
Currently subtraction of two pointers is constrained the same as in C, meaning that only pointers to qualified or unqualified versions of the same complete object type are allowed. This has some bizarre consequences:
static_assert(std::sentinel_for<const char*const*,char**>);
static_assert(!std::sized_sentinel_for<const char*const*,char**>);
const char*const* is a sentinel for char**, but it is not a sized sentinel for char**. There does not appear to be any fundamental reason why this is the case. It is also valid to mix these types in conditional operators, for example:
const char*const*p=0;
char**q=0;
auto r=0?p:q;//deduced type const char*const*
Therefore q-p is invalid but (0?p:q)-p is valid.
Suggested resolution:
Modify [expr.add]/2.2:
both operands are similar pointers to cv-qualified or cv-unqualified versions of the same completely-defined object types; or
Or, if it should be phrased as the types of the pointers being similar:
both operands are pointers to cv-qualified or cv-unqualified versions of the samesimilar completely-defined object types; or
Full name of submitter (unless configured in github; will be published with the issue): Jay Ghiron
Reference (section label): [expr.add]/2
Issue description:
Currently subtraction of two pointers is constrained the same as in C, meaning that only pointers to qualified or unqualified versions of the same complete object type are allowed. This has some bizarre consequences:
const char*const*is a sentinel forchar**, but it is not a sized sentinel forchar**. There does not appear to be any fundamental reason why this is the case. It is also valid to mix these types in conditional operators, for example:Therefore
q-pis invalid but(0?p:q)-pis valid.Suggested resolution:
Modify [expr.add]/2.2:
Or, if it should be phrased as the types of the pointers being similar: