[Bug c++/97358] [8/9/10 Regression] ICE while building firefox since r8-2720

richard-gccbugzilla at metafoo dot co.uk gcc-bugzilla@gcc.gnu.org
Fri Oct 16 00:32:19 GMT 2020


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

Richard Smith <richard-gccbugzilla at metafoo dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |richard-gccbugzilla@metafoo
                   |                            |.co.uk

--- Comment #19 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
(In reply to Jason Merrill from comment #10)
> This doesn't look valid to me.  In
> 
>   [x...] { x; }...
> 
> we capture the entire pack, but then try to use only a single element.  This
> should be rejected because the use of x in the lambda body is not expanded

The reference to 'x' is expanded within the scope of the parameter pack, though
(which is the entire function template, because 'x' here refers to the
parameter of the enclosing function template). So I think that case 2 is valid,
and expands to

foo(
  [x...] { return x.[0]; },
  [x...] { return x.[1]; },
  ...
  [x...] { return x.[N]; },
);

(That is, each lambda captures the entire pack and then uses only part of it.)
More generally, I think cases such as

foo([x...] { return f(x..., x); } ...);

... are valid, resulting in expansions such as

foo(
  [x...] { return f(x.[0], x.[1], ..., x.[N], x.[0]; },
  [x...] { return f(x.[0], x.[1], ..., x.[N], x.[1]; },
  ...
  [x...] { return f(x.[0], x.[1], ..., x.[N], x.[N]; },
);

I think Case 3 is not valid because the reference to the pack y is not expanded
*within the scope of that pack*, though it's not clear that the standard
actually clearly says that anywhere.


More information about the Gcc-bugs mailing list