From 4e7739b25ab46d9c573222680ad2862d263c909e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 8 Aug 2015 18:01:29 -0400 Subject: [PATCH] re PR c++/67159 ([c++concepts] Segfault while diagnosing constraint violation) PR c++/67159 * constraint.cc (finish_template_introduction): SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT. From-SVN: r226738 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/constraint.cc | 1 + gcc/testsuite/g++.dg/concepts/diagnostic1.C | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/g++.dg/concepts/diagnostic1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 32392395a22..f04b15c0f62 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2015-08-08 Jason Merrill + PR c++/67159 + * constraint.cc (finish_template_introduction): + SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT. + PR c++/67142 * pt.c (equal): Make sure tmpl is actually a template. diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index cf57cc010a4..c981212271d 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -1337,6 +1337,7 @@ finish_template_introduction (tree tmpl_decl, tree intro_list) tree parm = TREE_VEC_ELT (parm_list, n); TREE_VEC_ELT (check_args, n) = template_parm_to_arg (parm); } + SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (check_args, n); /* If the template expects more parameters we should be able to use the defaults from our deduced concept. */ diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic1.C b/gcc/testsuite/g++.dg/concepts/diagnostic1.C new file mode 100644 index 00000000000..7c360cc3943 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/diagnostic1.C @@ -0,0 +1,16 @@ +// PR c++/67159 +// { dg-options -std=c++1z } + +template +concept bool R = requires (T& t) { + { t.begin() } -> T +}; + +struct foo { + int* begin(); +}; + +R{T} +constexpr bool f() { return true; } + +static_assert(f()); // { dg-error "" } -- 2.30.2