diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6af8a20af12eb19e18008f9ccd2ed9758d8e5487..3d412443a7be567d126cd02594eeff148153a975 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2010-04-07  Dodji Seketeli  <dodji@redhat.com>
+
+	PR c++/42697
+	*pt.c (tsubst_decl): Get the arguments of a specialization from
+	the specialization template, not from the most general template.
+
 2010-04-07  Dodji Seketeli  <dodji@redhat.com>
 
 	PR c++/40239
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0bd55e1190c310cec83f9371cce54e1f4beb674c..13bb5aadf4d185bf74781d7e07217b7b15560567 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9020,7 +9020,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 	       specialize R.  */
 	    gen_tmpl = most_general_template (DECL_TI_TEMPLATE (t));
 	    argvec = tsubst_template_args (DECL_TI_ARGS
-					   (DECL_TEMPLATE_RESULT (gen_tmpl)),
+                                          (DECL_TEMPLATE_RESULT
+                                                 (DECL_TI_TEMPLATE (t))),
 					   args, complain, in_decl);
 
 	    /* Check to see if we already have this specialization.  */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 65c9f0235e8953fa505519f860eba60f0b6bbd2a..0032dd813b0d6b1df11003f8cee7f4dcbdb1dbbd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-07  Dodji Seketeli  <dodji@redhat.com>
+
+	PR c++/42697
+	* g++.dg/template/crash94.C: New test.
+
 2010-04-07  Dodji Seketeli  <dodji@redhat.com>
 
 	PR c++/40239
diff --git a/gcc/testsuite/g++.dg/template/crash94.C b/gcc/testsuite/g++.dg/template/crash94.C
new file mode 100644
index 0000000000000000000000000000000000000000..810aed0a61c6e97a1222e76130ad1f6e4e8fb382
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/crash94.C
@@ -0,0 +1,28 @@
+// Origin: PR c++/42697
+// { dg-do compile }
+
+template<class Value_t>
+class fparser
+{
+    template<bool Option>
+    void eval2(Value_t r[2]);
+public:
+    void evaltest();
+};
+
+template<>
+template<bool Option>
+void fparser<int>::eval2(int r[2])
+{
+    struct ObjType {};
+}
+
+
+template<class Value_t>
+void fparser<Value_t>::evaltest
+    ()
+{
+    eval2<false>(0);
+}
+
+template class fparser<int>;