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

            Bug ID: 67774
           Summary: [concepts] ICE when mismatching template arguments to
                    concept
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan.burn at gmail dot com
  Target Milestone: ---

Below code produces this ICE:

t.cpp: In function ‘int main()’:
t.cpp:21:16: error: wrong number of template arguments (1, should be 2)
   std::cout << cpt_KEvaluator<decltype(f)> << '\n';
                ^
t.cpp:16:48: note: provided for ‘template<class X, long unsigned int K>
constexpr const bool cpt_KEvaluator<X, K>’
 template <class X, std::size_t K> concept bool cpt_KEvaluator =
                                                ^
t.cpp:21:16: internal compiler error: tree check: expected tree_vec, have
error_mark in tsubst, at cp/pt.c:12570
   std::cout << cpt_KEvaluator<decltype(f)> << '\n';
                ^
0xf2508c tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.c:9512
0x6642bc tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:2858
0x6642bc tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:12570
0x676b70 tsubst_copy
        ../../gcc/gcc/cp/pt.c:13675
0x680c0a tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:15474
0x66aad1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:15044
0x66fbbc tsubst_template_arg
        ../../gcc/gcc/cp/pt.c:10260
0x67cd12 tsubst_template_args
        ../../gcc/gcc/cp/pt.c:10839
0x6621c1 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:12829
0x6623bf tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:12452
0x67cd12 tsubst_template_args
        ../../gcc/gcc/cp/pt.c:10839
0x67fafb tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:15230
0x66aad1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:15044
0x823207 satisfy_predicate_constraint
        ../../gcc/gcc/cp/constraint.cc:1694
0x823207 satisfy_constraint_1
        ../../gcc/gcc/cp/constraint.cc:1898
0x823f76 satisfy_constraint
        ../../gcc/gcc/cp/constraint.cc:1949
0x797988 finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*,
bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int)
        ../../gcc/gcc/cp/semantics.c:3585
0x702615 cp_parser_primary_expression
        ../../gcc/gcc/cp/parser.c:4817
0x70ec1b cp_parser_postfix_expression
        ../../gcc/gcc/cp/parser.c:6201
0x713679 cp_parser_unary_expression
        ../../gcc/gcc/cp/parser.c:7486
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

//////////////////////////////////////////////////////////////////
#include <type_traits>
#include <utility>
#include <iostream>

template <class X> concept bool cpt_RealScalar() {
  return std::is_floating_point<X>::value;
}

namespace detail {
template <class, class> constexpr bool k_evaluator_impl = false;

template <std::size_t... Indexes, class E>
constexpr bool k_evaluator_impl<std::index_sequence<Indexes...>, E> = true;
}

template <class X, std::size_t K> concept bool cpt_KEvaluator =
  detail::k_evaluator_impl<std::make_index_sequence<K>, X>;

int main() {
  auto f = [](int, int, int) -> double { return 3; };
  std::cout << cpt_KEvaluator<decltype(f)> << '\n';
  return 0;
}
//////////////////////////////////////////////////////////////////

Reply via email to