re PR c++/80186 (ICE on C++ code with invalid constructor: Segmentation fault (progra...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 9 May 2017 16:56:34 +0000 (16:56 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 9 May 2017 16:56:34 +0000 (16:56 +0000)
/cp
2017-05-09  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/80186
* pt.c (tsubst_decl): Early return error_mark_node if
grok_ctor_properties returns false.

/testsuite
2017-05-09  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/80186
* g++.dg/template/crash126.C: New.

From-SVN: r247807

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash126.C [new file with mode: 0644]

index a5990e2..6b899d1 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-09  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/80186
+       * pt.c (tsubst_decl): Early return error_mark_node if
+       grok_ctor_properties returns false.
+
 2017-05-09  Jason Merrill  <jason@redhat.com>
 
        PR c++/70167 - array prvalue treated as lvalue
index a4a0d83..0a8298c 100644 (file)
@@ -12407,8 +12407,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
        if (DECL_CONSTRUCTOR_P (r) || DECL_DESTRUCTOR_P (r))
          {
            maybe_retrofit_in_chrg (r);
-           if (DECL_CONSTRUCTOR_P (r))
-             grok_ctor_properties (ctx, r);
+           if (DECL_CONSTRUCTOR_P (r) && !grok_ctor_properties (ctx, r))
+             RETURN (error_mark_node);
            /* If this is an instantiation of a member template, clone it.
               If it isn't, that'll be handled by
               clone_constructors_and_destructors.  */
index d0c083d..68d9e3f 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-09  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/80186
+       * g++.dg/template/crash126.C: New.
+
 2017-05-09  Sebastian Peryt  <sebastian.peryt@intel.com>
 
        * gcc.target/i386/avx512f-vaddsd-2.c: Test fixed.
diff --git a/gcc/testsuite/g++.dg/template/crash126.C b/gcc/testsuite/g++.dg/template/crash126.C
new file mode 100644 (file)
index 0000000..8a3112e
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/80186
+
+template < class T, class > struct A
+{
+  A ();
+  A (A &);
+  A (A < T, T >);  // { dg-error "invalid constructor" }
+};
+
+void f () 
+{
+  A < int, int > (A < int, int >());  // { dg-error "cannot bind" }
+}