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

--- Comment #7 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to CVS Commits from comment #6)
> The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:
> 
> https://gcc.gnu.org/g:fe993b469c528230d9a01e1ae2208610f960dd9f
> 
> commit r12-856-gfe993b469c528230d9a01e1ae2208610f960dd9f
> Author: Patrick Palka <ppa...@redhat.com>
> Date:   Tue May 18 00:28:44 2021 -0400
> 
>     libstdc++: Fix up semiregular-box partial specialization [PR100475]
>     
>     This makes the in-place constructor of our partial specialization of
>     __box for already-semiregular types perform
> direct-non-list-initialization
>     (in accordance with the specification of the primary template), and
>     additionally makes the member function data() use std::__addressof.
>     
>     libstdc++-v3/ChangeLog:
>     
>             PR libstdc++/100475
>             * include/std/ranges (__box::__box): Use non-list-initialization
>             in member initializer list of in-place constructor of the
>             partial specialization for semiregular types.
>             (__box::operator->): Use std::__addressof.
>             * testsuite/std/ranges/adaptors/detail/semiregular_box.cc
>             (test02): New test.
>             * testsuite/std/ranges/single_view.cc (test04): New test.


I think that even list-initialization with a single parameter should be changed
to direct-non-list-initialization to avoid bugs in some uncommon situations.



#include <ranges>

struct S {
  S() = default;
  S(std::initializer_list<S>) = delete;
  S(const S&) {}
};
S obj;

auto l = std::initializer_list<S>{{}, {}};
auto x = std::views::single(obj);
auto y = std::views::single(std::move(l));

https://godbolt.org/z/7nePj6Y57

Reply via email to