Bug 85305

Summary: Parameter pack expression in lambda capture list fails as part of a fold expression
Product: gcc Reporter: Vittorio Romeo <vittorio.romeo>
Component: c++Assignee: Jason Merrill <jason>
Status: RESOLVED FIXED    
Severity: normal CC: jason, webrown.cpp
Priority: P3 Keywords: rejects-valid
Version: 8.0.1   
Target Milestone: 8.2   
Host: Target:
Build: Known to work: 9.0
Known to fail: Last reconfirmed: 2018-04-09 00:00:00

Description Vittorio Romeo 2018-04-09 18:59:25 UTC
The following code snippet...

    template <int... Is>
    void foo()
    {
        ([i = Is]{}(), ...); 
    }

...does not compile on gcc trunk 20180408 with the following error:

    <source>: In function 'void foo()':
    <source>:4:11: error: parameter packs not expanded with '...':
         ([i = Is]{}(), ...);
               ^~

    <source>:4:11: note:         'Is'
    <source>:4:16: error: operand of fold expression has no unexpanded parameter packs
         ([i = Is]{}(), ...);
          ~~~~~~~~~~^~

Live example on godbolt.org:
https://godbolt.org/g/YBk6L6
Comment 1 Jason Merrill 2018-04-30 21:21:57 UTC
Author: jason
Date: Mon Apr 30 21:21:25 2018
New Revision: 259779

URL: https://gcc.gnu.org/viewcvs?rev=259779&root=gcc&view=rev
Log:
	PR c++/85305 - pack in lambda init-capture.

	* parser.c (cp_parser_initializer): Add subexpression_p parm; don't
	check_for_bare_parameter_packs in a subexpression.
	(cp_parser_lambda_introducer): Use it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1z/fold-lambda2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
Comment 2 Jason Merrill 2018-04-30 21:26:20 UTC
Fixed on trunk so far.
Comment 3 Jason Merrill 2018-05-04 20:20:51 UTC
Author: jason
Date: Fri May  4 20:20:16 2018
New Revision: 259959

URL: https://gcc.gnu.org/viewcvs?rev=259959&root=gcc&view=rev
Log:
	PR c++/85305 - pack in lambda init-capture.

	* parser.c (cp_parser_initializer): Add subexpression_p parm; don't
	check_for_bare_parameter_packs in a subexpression.
	(cp_parser_lambda_introducer): Use it.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp1z/fold-lambda2.C
Modified:
    branches/gcc-8-branch/gcc/cp/ChangeLog
    branches/gcc-8-branch/gcc/cp/parser.c
Comment 4 Jason Merrill 2018-05-04 20:21:14 UTC
Fixed for 8.2.