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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Richard Biener from comment #2)
> > The diagnostic is intentional I think.  We see
> > 
> > <bb 2> [local count: 1073741824]:
> > ss ={v} {CLOBBER};
> > std::stop_token::_Stop_state_ref::_Stop_state_ref (&ss._M_state, &ss);
> > std::stop_source::~stop_source (&ss);
> > ss ={v} {CLOBBER(eol)};
> > return 0;
> > 
> > and the call to _Stop_state_ref passes references to uninitialized 'ss'
> > (tree-ssa-uninit.cc:maybe_warn_pass_by_reference).  The &ss argument
> > is a const reference and the function does
> > 
> >       _Stop_state_ref(const _Stop_state_ref& __other) noexcept
> 
> That function is never used in this code though. Why is code being emitted
> for it?

Actually I don't think any code is being emitted for it, so that's fine. That
function is a red herring, but not involved here at all.

The warning is for this one:

> We don't copy a _Stop_state_ref, we construct one using this constructor:
> 
>       _Stop_state_ref(const stop_source&)
>       : _M_ptr(new _Stop_state_t())
>       { }
> 
> This has a reference to ss but doesn't inspect it at all.

It can't inspect it, because it's not even named. The function has no way to
possibly access the uninitialized object through that reference.

Reply via email to