Re: which compiler is right (either to compile or to barf)...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 2, 2022 at 6:45 PM LIU Hao <lh_mouse@xxxxxxx> wrote:

> 在 2022/12/2 15:18, leon zadorin via Gcc-help 写道:
> > (1) On the one hand, given that I do instantiate ::std::optional with S
> > (whith has member v whose elements' types, I guess(?) are at the line of
> > declaring 'static ::std::optional<S> s', are still incompletely denifed,
> > i.e. X) -- the clang discussion appears to say that at this moment
> optional
> > is instantiated and S is incomplete (?) ... as so it is a UB... which I
> > understood Jonathan's comment to relate to as well.
> >
>
> Yes this requires `S` to be complete.
>
...

>
> Only `S` itself is required to be complete.
>
>
> In your code:
>
>    struct S {
>        ::std::vector<::std::shared_ptr<J<X>>> v;
>    };
>
> `S` _is_ complete. It does not matter whether it contains a `vector` of or
> a `shared_ptr` to
> incomplete types, because the standard allows so. ([vector.overview] 4,
> [util.smartptr.shared] 2)
>

ah..., ok -- thanks very much for explaining! If that is the case then
indeed you are correct -- there is no UB it would seem (I had updated the
comment in clang discussion
https://github.com/llvm/llvm-project/issues/59292#issuecomment-1334898870 ,
hopefully they may re-open the issue then :) . Many thanks for clarifying
:)




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux