https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115218

            Bug ID: 115218
           Summary: The conversion constructor of concat_view::iterator
                    always default-constructs variant
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

constexpr
    iterator(iterator<!_Const> __it)
      requires _Const && (convertible_to<iterator_t<_Vs>, iterator_t<const
_Vs>> && ...)
    : _M_parent(__it._M_parent)
    {
      _M_invoke_with_runtime_index([this, &__it]<size_t _Idx>() {
        _M_it.template emplace<_Idx>(std::get<_Idx>(std::move(__it._M_it)));
      });
    }

This constructor always default-constructs variant which may not be
well-formed:

https://godbolt.org/z/YndEKGhz5

#include <ranges>

struct I {
  I() = delete;
  I(int*);
  using value_type = int;
  using difference_type = int;
  value_type& operator*() const;
  I& operator++();
  void operator++(int);
};

struct R {
  int* begin();
  I begin() const;
  std::unreachable_sentinel_t end() const;
};

int main() {
  auto c = std::ranges::concat_view{R{}};
  const auto& cr = c;
  decltype(cr.begin()) it = c.begin(); // hard error
}

Reply via email to