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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2026-03-20

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This isn't related to expansion stmts, but is a bug in the pack indexing
support.
https://eel.is/c++draft/expr.prim.pack.index#2
says that the index should be a converted constant expression of type
std::size_t and I think the conversion should ensure also mark_rvalue_use.
So, we shouldn't warn on
template <int ...N>
int
foo ()
{
  constexpr int a = 1;
  return N...[a];
}

int b = foo <1, 2, 3> ();
that a is set but not used, but should also accept
struct A { constexpr A () : a (1) {} int a; constexpr operator int () const {
return a; } };

template <int ...N>
int
foo ()
{
  constexpr A a;
  return N...[a];
}

int a = foo <1, 2, 3> ();
which we currently reject with
error: pack index has non-integral type ‘A’

Reply via email to