This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

3358. §[span.cons] is mistaken that to_address can throw

Section: 24.7.2.2.2 [span.cons] Status: C++20 Submitter: Casey Carter Opened: 2019-12-10 Last modified: 2021-02-25

Priority: 0

View all other issues in [span.cons].

View all issues with C++20 status.

Discussion:

[span.cons] paragraphs 6 and 9:

Throws: When and what to_address(first) throws.

could equivalently be "Throws: Nothing." since all overloads of std::to_address are noexcept. However, paragraph 9 fails to account for the fact that paragraph 8:

Effects: Initializes data_ with to_address(first) and size_ with last - first.

must evaluate last - first.

[2020-01-14 Status set to Tentatively Ready after ten positive votes on the reflector.]

[2020-01-14; Daniel comments]

The fixed wording in 24.7.2.2.2 [span.cons] p9 depends on the no-throw-guarantee of integer-class conversions to integral types. This guarantee is specified by LWG 3367.

Proposed resolution:

This wording is relative to N4842.

  1. Modify 24.7.2.2.2 [span.cons] paragraphs 6 and 9 as indicated:

    [Drafting note:

    1. The missing paragraph number of the Preconditions element at p7/p8 has already been reported as editorial issue

    2. The effective change to "Throws: Nothing." in p6 has already been applied editorially.

    ]

    template<class It>
      constexpr span(It first, size_type count);
    

    […]

    -4- Preconditions: […]

    -5- Effects: Initializes data_ with to_address(first) and size_ with count.

    -6- Throws: When and what to_address(first) throwsNothing.

    template<class It, class End>
      constexpr span(It first, End last);
    

    […]

    -?- Preconditions: […]

    -8- Effects: Initializes data_ with to_address(first) and size_ with last - first.

    -9- Throws: When and what to_address(first)last - first throws.