Bug 67774 - [concepts] ICE when mismatching template arguments to concept
Summary: [concepts] ICE when mismatching template arguments to concept
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 10.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: concepts
  Show dependency treegraph
 
Reported: 2015-09-30 01:00 UTC by ryan.burn
Modified: 2020-04-29 16:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Patch against concepts-cxx2a to add test (git format-patch format) (863 bytes, application/mbox)
2019-09-04 21:02 UTC, Andrew Sutton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ryan.burn 2015-09-30 01:00:27 UTC
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;
}
//////////////////////////////////////////////////////////////////
Comment 1 Andrew Sutton 2019-09-04 21:02:20 UTC
Created attachment 46825 [details]
Patch against concepts-cxx2a to add test (git format-patch format)

This was previously fixed in the concepts-cxx2a branch. Providing a patch that adds a test for the PR.
Comment 2 Patrick Palka 2020-04-29 16:22:22 UTC
Fixed for GCC 10 then.