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

            Bug ID: 87844
           Summary: ICE in tsubst_copy using non-constant expression as a
                    non-type template argument
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: curlypaul924 at gmail dot com
  Target Milestone: ---

The following code causes ICE in every version I tried from 4.9.0 through 8.2,
as well as trunk:

struct C {
  static constexpr bool call(bool) { return true; }
};

template<bool b>
struct B {};

auto foo(bool b) {
  auto f = [](auto c) -> B<decltype(c)::call(b)> { };
  f(C());
}

int main() {
  foo(true);
}

Compile with either -std=c++14 or -std=c++17.

Clang (I believe correctly) rejects this code with "non-type template argument
is not a constant expression".

Reply via email to