https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66092
Bug ID: 66092 Summary: Concept can't check variadic template arguments Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yingpo.liao at gmail dot com Target Milestone: --- Concept can't check variadic template arguments (r222891). The example code shows an implementation of a concept to check if all types are the same via variadic template arguments. It will be okay if we directly print out the results, but will fail (internal compiler error) if we apply the concept to real cases, i.e., a foo() function. $ svn info Path: . Working Copy Root Path: /Users/liao/Downloads/gcc-branch-c++-concepts/c++-concepts URL: svn://gcc.gnu.org/svn/gcc/branches/c++-concepts Relative URL: ^/branches/c++-concepts Repository Root: svn://gcc.gnu.org/svn/gcc Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4 Revision: 222891 Node Kind: directory Schedule: normal Last Changed Author: asutton Last Changed Rev: 222891 Last Changed Date: 2015-05-07 15:25:15 -0500 (Thu, 07 May 2015) $ cat test.cpp #include <iostream> #include <type_traits> template <typename T, typename U, typename... Args> requires (sizeof...(Args) == 0) constexpr decltype(auto) check() { return std::integral_constant<bool, __is_same_as(T, U)>(); } template <typename T, typename U, typename... Args> requires (sizeof...(Args) > 0) constexpr decltype(auto) check() { return std::integral_constant<bool, __is_same_as(T, U) && decltype(check<U, Args...>())::value>(); } template <typename T, typename U, typename... Args> concept bool Same() { return decltype(check<T, U, Args...>())::value; } template <typename... Args> requires Same<Args...>() void foo( Args... args ) {} int main() { // OK: print "true" std::cout << std::boolalpha << Same<int, int, int>() << std::endl; // ERROR foo(1, 2, 3); return 0; } $ g++ -std=c++1z test.cpp -o test test.cpp:22:41: internal compiler error: tree check: accessed elt 2 of tree_vec with 1 elts in tsubst, at cp/pt.c:12556 return decltype(check<T, U, Args...>())::value; ^ test.cpp:22:41: internal compiler error: Abort trap: 6 g++: internal compiler error: Abort trap: 6 (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.