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

            Bug ID: 100475
           Summary: semiregular-box's constructor uses wrong
                    list-initialization
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

The specialization of semiregular-box's constructor in ranges#L166:

template<typename... _Args>
  requires constructible_from<_Tp, _Args...>
  constexpr explicit
  __box(in_place_t, _Args&&... __args)
  noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
  : _M_value{std::forward<_Args>(__args)...}
  { }

uses the wrong list-initialization, which will incorrectly construct the vector
with the initializer list in the following example:

#include <iostream>
#include <ranges>
#include <vector>

int main() {
  std::ranges::single_view<std::vector<int>> single(std::in_place, 100, 0);
  std::cout << single.begin()->size() << "\n"; 
}

https://godbolt.org/z/c88o3WzYP

Reply via email to