https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102999
Bug ID: 102999
Summary: g++-11 regression: sorry, unimplemented: unexpected
AST of kind nontype_argument_pack
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cantonios at google dot com
Target Milestone: ---
The following code works with g++ in versions prior to 11, as well as all
versions of clang, but fails as of at least 11.1 (according to godbolt).
---
#include <type_traits>
template<typename T, T... nn>
struct numeric_list {};
template<class a, class b> struct concat;
template<typename T, T... as, T... bs>
struct concat<numeric_list<T, as...>, numeric_list<T, bs...> > { typedef
numeric_list<T, as..., bs...> type; };
template<int n, typename x> struct take;
// The following fail in gcc-11.*.
template<typename T, int n, T a, T... as> struct take<n, numeric_list<T, a,
as...>> : concat<numeric_list<T, a>, typename take<n-1, numeric_list<T,
as...>>::type> {};
template<typename T, int n> struct take<n, numeric_list<T>>
{ typedef numeric_list<T> type; };
template<typename T, T a, T... as> struct take<0, numeric_list<T, a,
as...>> { typedef numeric_list<T> type; };
template<typename T> struct take<0, numeric_list<T>>
{ typedef numeric_list<T> type; };
int main() {
typedef numeric_list<int, 0, 1, 2, 3, 4, 5> a;
typedef typename take<6, a>::type b;
return 0;
}
---
<source>: In instantiation of 'struct take<1, numeric_list<int, 5> >':
<source>:13:50: recursively required from 'struct take<5, numeric_list<int,
1, 2, 3, 4, 5> >'
<source>:13:50: required from 'struct take<6, numeric_list<int, 0, 1, 2, 3,
4, 5> >'
<source>:20:30: required from here
<source>:13:50: sorry, unimplemented: unexpected AST of kind
nontype_argument_pack
13 | template<typename T, int n, T a, T... as> struct take<n,
numeric_list<T, a, as...>> : concat<numeric_list<T, a>, typename take<n-1,
numeric_list<T, as...>>::type> {};
|
---
https://godbolt.org/z/4fMafha3z
Local version info:
$ g++-11 --version
g++-11 (Debian 11.2.0-8) 11.2.0
The code is extracted from Eigen
(https://gitlab.com/libeigen/eigen/-/blob/master/unsupported/Eigen/CXX11/src/util/CXX11Meta.h).
We're trying to expand our CI coverage, and noticed that it fails to build for
gcc-11.