Bug 85305 - Parameter pack expression in lambda capture list fails as part of a fold expression
Summary: Parameter pack expression in lambda capture list fails as part of a fold expr...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P3 normal
Target Milestone: 8.2
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-04-09 18:59 UTC by Vittorio Romeo
Modified: 2018-05-04 20:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 9.0
Known to fail:
Last reconfirmed: 2018-04-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.