[Bug c++/97938] [9/10/11 Regression] g++ crash when inferring type of auto parameter pack in lambda capture

2021-04-02 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97938

--- Comment #4 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:2a26351b598242c2fbce95d2a0baacce0084aec6

commit r11-7961-g2a26351b598242c2fbce95d2a0baacce0084aec6
Author: Jason Merrill 
Date:   Fri Apr 2 11:05:46 2021 -0400

c++: lambda pack init-capture within generic lambda

We represent the type of a pack init-capture as auto... with packs from the
initializer stuck into PACK_EXPANSION_PARAMETER_PACKS so that expanding it
produces the right number of elements.  But when partially instantiating
the
auto..., we were changing PACK_EXPANSION_PARAMETER_PACKS to refer to only
the auto itself.  Fixed thus.

gcc/cp/ChangeLog:

PR c++/97938
* cp-tree.h (PACK_EXPANSION_AUTO_P): New.
* lambda.c (add_capture): Set it.
* pt.c (tsubst_pack_expansion): Handle it.

gcc/testsuite/ChangeLog:

PR c++/97938
* g++.dg/cpp2a/lambda-pack-init6.C: New test.

[Bug c++/97938] [9/10/11 Regression] g++ crash when inferring type of auto parameter pack in lambda capture

2021-04-01 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97938

--- Comment #3 from Jason Merrill  ---
Reduced more:

template 
int sink(Args&&... args) { return 2; }

template 
auto fwd(const T1& t1) {
  return
[] (auto&&... ts1) {
  return
[...ts1 = ts1] () {
  return sink(ts1...);
}();
}();
}

int main() {
  return fwd(1);
}

[Bug c++/97938] [9/10/11 Regression] g++ crash when inferring type of auto parameter pack in lambda capture

2021-04-01 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97938

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||jason at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org

--- Comment #2 from Jason Merrill  ---
Removed library dependency:

template 
auto apply(F&& f, Args&&... args) { return f(args...); }

template  T&& forward(T&& t);

template 
int print_args(Args&&... args) {
  return sizeof...(args);
}

template 
auto fwd(const T1& t1, const T2& t2) {
  return ::apply([] (auto&&... ts1) {
return ::apply([...ts1 = forward(ts1)] (auto&&... ts2) {
  return print_args(ts1..., forward(ts2)...);
}, t2);
  }, t1);
}

int main() {
  auto t1 = 1;
  auto t2 = 2;
  return fwd(t1, t2);
}

[Bug c++/97938] [9/10/11 Regression] g++ crash when inferring type of auto parameter pack in lambda capture

2020-11-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97938

Richard Biener  changed:

   What|Removed |Added

Summary|9/10/11 Regression]  g++|[9/10/11 Regression]  g++
   |crash when inferring type   |crash when inferring type
   |of auto parameter pack in   |of auto parameter pack in
   |lambda capture  |lambda capture
   Keywords||ice-on-valid-code
   Priority|P3  |P2

[Bug c++/97938] 9/10/11 Regression] g++ crash when inferring type of auto parameter pack in lambda capture

2020-11-22 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97938

Marek Polacek  changed:

   What|Removed |Added

Summary|g++ crash when inferring|9/10/11 Regression]  g++
   |type of auto parameter pack |crash when inferring type
   |in lambda capture   |of auto parameter pack in
   ||lambda capture
   Target Milestone|--- |9.4