On Thu, 24 Jun 2021 at 19:54, Patrick Palka <ppa...@redhat.com> wrote:
>
> On Thu, 24 Jun 2021, Jonathan Wakely via Libstdc++ wrote:
>
> > The LWG issue proposes to add a conditional noexcept-specifier to
> > std::unique_ptr's dereference operator. The issue is currently in
> > Tentatively Ready status, but even if it isn't voted into the draft, we
> > can do it as a conforming extensions. This commit also adds a similar
> > noexcept-specifier to operator[] for the unique_ptr<T[], D> partial
> > specialization.
>
> The conditional noexcept added to unique_ptr<T[]>::operator[] seems to break
> the case where T is complete only after the fact:
>
>   struct T;
>   extern std::unique_ptr<T[]> p;
>   auto& t = p[1];
>   struct T { };
>
> /include/c++/12.0.0/bits/unique_ptr.h: In instantiation of ‘typename 
> std::add_lvalue_reference<_Tp>::type std::unique_ptr<_Tp [], 
> _Dp>::operator[](std::size_t) co
> nst [with _Tp = A; _Dp = std::default_delete<A []>; typename 
> std::add_lvalue_reference<_Tp>::type = A&; std::size_t = long unsigned int]’:
> testcase.cc:5:14:   required from here
> /include/c++/12.0.0/bits/unique_ptr.h:658:48: error: invalid use of 
> incomplete type ‘struct A’
>   658 |       
> noexcept(noexcept(std::declval<pointer>()[std::declval<size_t&>()]))
>       |                         ~~~~~~~~~~~~~~~~~~~~~~~^
> testcase.cc:3:8: note: forward declaration of ‘struct A’
>     3 | struct A;
>       |        ^

OK, I'll remove that again.

Reply via email to