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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, I suppose I was misled by trying to trace how the construction works.  The
first half of my comment#2 still stands - we diagnose

  ss ={v} {CLOBBER};
  std::stop_token::_Stop_state_ref::_Stop_state_ref (&ss._M_state, &ss);

by (maybe broken) design, the &ss argument is a const reference which
we decide implies read. In this case we could even use modref to
see the parameter is unused - but the call happens through an alias
and in the -Og pipeline we do not run late modref.

The called body is

void std::stop_token::_Stop_state_ref::_Stop_state_ref (struct _Stop_state_ref
* const this, const struct stop_source & D.79270)
{
  void * _5;

  <bb 2> [local count: 1073741824]:
  _5 = operator new (24);
  MEM[(struct _Stop_state_t *)_5]._M_owners.D.16955._M_i = 0;
  MEM[(struct _Stop_state_t *)_5]._M_value.D.16955._M_i = 0;
  MEM[(struct _Stop_state_t *)_5]._M_head = 0B;
  MEM[(struct _Stop_state_t *)_5]._M_requester._M_thread = 0;
  MEM[(struct __atomic_base *)_5]._M_i = 1;
  MEM[(struct __atomic_base *)_5 + 4B]._M_i = 4;
  MEM[(struct id *)_5 + 16B]._M_thread = 0;
  this_2(D)->_M_ptr = _5;
  return;

}

but since this function can be interposed even modref doesn't help (when
scheduled and enabled) since it throws away this knowledge :/  Maybe
we need some optimistic mode for diagnostic code (or add
EAF_LIKELY_UNUSED).

But as said (late) modref isn't in the -Og pipeline and it's only enabled
with -O2+ anyway.

The other possible heuristic adjustment would be noticing &ss is also
passed as first non-const reference argument.

Reply via email to