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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12/13 Regression]    |[10/11/12/13 Regression]
                   |ICE on constexpr variable   |ICE on constexpr variable
                   |used as nontype template    |used as nontype template
                   |since                       |since
                   |e32fc4499f863fe0fa81767d11f |r9-5473-ge32fc4499f863f
                   |40ad2f1ab1668               |

--- Comment #12 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #11)
> Started with r268016
... aka r9-5473-ge32fc4499f863f.


More reduced testcase:

template<class T>
void f() {
  constexpr int dim = 1;
  auto f = [&] {
    int n[dim * 1];
  };
}

template void f<int>();

<stdin>: In instantiation of ‘void f() [with T = int]’:
<stdin>:9:22:   required from here
<stdin>:5:11: internal compiler error: in lookup_template_class, at
cp/pt.cc:10080


We similarly crash when using a generic lambda:

template<class T>
void f() {
  constexpr int dim = 1;
  auto f = [&] (auto) {
    int n[dim * 1];
  };
  f(0);
}

template void f<int>();

In either case, since dim is a constant variable we should prune the implicit
capture of it and sizeof(f) should be 1.

Reply via email to