re PR c++/67159 ([c++concepts] Segfault while diagnosing constraint violation)
authorJason Merrill <jason@redhat.com>
Sat, 8 Aug 2015 22:01:29 +0000 (18:01 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 8 Aug 2015 22:01:29 +0000 (18:01 -0400)
PR c++/67159
* constraint.cc (finish_template_introduction):
SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT.

From-SVN: r226738

gcc/cp/ChangeLog
gcc/cp/constraint.cc
gcc/testsuite/g++.dg/concepts/diagnostic1.C [new file with mode: 0644]

index 32392395a220b0d88519435231179ae44e8b7e26..f04b15c0f628a815a43cbd7ef3bd15f4f6429638 100644 (file)
@@ -1,5 +1,9 @@
 2015-08-08  Jason Merrill  <jason@redhat.com>
 
+       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.
 
index cf57cc010a469babaf70962660459ee725882241..c981212271d4649cf2ba70517dbeae008d5ad90b 100644 (file)
@@ -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 (file)
index 0000000..7c360cc
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/67159
+// { dg-options -std=c++1z }
+
+template <class T>
+concept bool R = requires (T& t) {
+  { t.begin() } -> T
+};
+
+struct foo {
+  int* begin();
+};
+
+R{T}
+constexpr bool f() { return true; }
+
+static_assert(f<foo>());       // { dg-error "" }