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

3626. Is std::basic_stacktrace required to use contiguous storage?

Section: 19.6.4.1 [stacktrace.basic.overview] Status: New Submitter: Jiang An Opened: 2021-10-23 Last modified: 2022-01-29

Priority: 3

View all issues with New status.

Discussion:

Currently std::basic_stacktrace has an exposition-only std::vector member for storing its elements. According to 16.3.3.5 [objects.within.classes]/3, it seems that it is effectively required that elements of a std::basic_stacktrace are contiguously stored. However, the implication seems not used otherwhere. The iterator type of a std::basic_stacktrace is only required to be random access iterator.

IMO if it is required that std::basic_stacktrace uses contiguous storage, we should explicitly strengthen some requirements, perhaps a the member function data should be added.

[2022-01-29; Reflector poll]

Set priority to 3 after reflector poll.
"The problem here is that a handful of member functions (operator[], at, perhaps begin) expose references to the vector elements directly, which can be read to require contiguity. We should rephrase the members at issue to not do that."

Proposed resolution:

This wording is relative to N4901.

[Drafting note: The proposed wording below contains also conditional changes, it is therefore depending upon a decision]

  1. Modify 19.6.4.1 [stacktrace.basic.overview] as indicated:

    -1- The class template basic_stacktrace satisfies the requirements of an allocator-aware container (Table 80 [tab:container.alloc.req]), a sequence container (24.2.4 [sequence.reqmts]), a contiguous container, and a reversible container (24.2.2.1 [container.requirements.general]) except that […]

  2. Modify 19.6.4.3 [stacktrace.basic.obs] as indicated:

    using const_iterator = implementation-defined;
    

    -1- The type models random_access_iteratorcontiguous_iterator (25.3.4.13 [iterator.concept.random.access]25.3.4.14 [iterator.concept.contiguous]) and meets the Cpp17RandomAccessIterator requirements (25.3.5.7 [random.access.iterators]).

Optional additional changes (the following parts are proposed only if data() is wanted)

  1. Modify 19.6.4.1 [stacktrace.basic.overview], class template basic_stacktrace synopsis, as indicated:

    […]
    const_reference operator[](size_type) const;
    const_reference at(size_type) const;
    
    const stacktrace_entry* data() const noexcept;
    
    // 19.6.4.4 [stacktrace.basic.cmp], comparisons
    […]
    
  2. Modify 19.6.4.3 [stacktrace.basic.obs] as indicated:

    const_reference at(size_type frame_no) const;
    

    -13- […]

    -14- […]

    const stacktrace_entry* data() const noexcept;
    

    -?- Returns: frames_.data().