Title
random_access_iterator semantic constraints accidentally promote difference type using unary negate
Status
c++20
Section
[iterator.concept.random.access]
Submitter
Eric Niebler

Created on 2019-09-10.00:00:00 last changed 38 months ago

Messages

Date: 2019-10-12.11:33:15

Proposed resolution:

This wording is relative to N4830.

  1. Modify [iterator.concept.random.access] as indicated:

    -2- Let a and b be valid iterators of type I such that b is reachable from a after n applications of ++a, let D be iter_difference_t<I>, and let n denote a value of type D. I models random_access_iterator only if:

    1. (2.1) — (a += n) is equal to b.

    2. […]

    3. (2.7) — (b += D(-n)) is equal to a.

    4. […]

Date: 2019-10-12.00:00:00

[ 2019-10-12 Issue Prioritization ]

Status to Tentatively Ready and priority to 0 after five positive votes on the reflector.

Date: 2019-09-10.00:00:00

[iterator.concept.random.access]/p2.7 says:

(b += -n) is equal to a

Unary minus can do integer promotion. That is not the intent here.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: voting -> wp
2020-01-17 04:54:50adminsetstatus: ready -> voting
2019-10-12 11:33:15adminsetmessages: + msg10695
2019-10-12 11:33:15adminsetstatus: new -> ready
2019-09-16 19:24:35adminsetmessages: + msg10639
2019-09-10 00:00:00admincreate