diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 5dad6776199d4dc79ef50f036c13f035a161de71..2ce1ec667f66a1cd8cebc32ab05c991a6eb1d952 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-04  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/29821
+	* resolve.c (resolve_operator): Only return result of
+	gfc_simplify_expr if expression is constant.
+
 2006-12-04  Paul Thomas  <pault@gcc.gnu.org>
 
 	PR fortran/29916
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 75a6ca31b8f5730e740057ad745da5b73105996c..e31ecbd5909e8f6cb3c2f88037f188bc9fb703d4 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -2191,7 +2191,14 @@ resolve_operator (gfc_expr * e)
 
   /* Attempt to simplify the expression.  */
   if (t == SUCCESS)
-    t = gfc_simplify_expr (e, 0);
+    {
+      t = gfc_simplify_expr (e, 0);
+      /* Some calls do not succeed in simplification and return FAILURE
+	 even though there is no error; eg. variable references to
+	 PARAMETER arrays.  */
+      if (!gfc_is_constant_expr (e))
+	t = SUCCESS;
+    }
   return t;
 
 bad_op:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0d558084d4a1157991948972a39127d20f605439..a0c4f78d2277e086275d5a1e8b976647403ae64c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-04  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/29821
+	* gfortran.dg/parameter_array_section_1.f90: New test.
+
 2006-12-04  Mark Mitchell  <mark@codesourcery.com>
 
 	PR c++/29733
diff --git a/gcc/testsuite/gfortran.dg/parameter_array_section_1.f90 b/gcc/testsuite/gfortran.dg/parameter_array_section_1.f90
new file mode 100644
index 0000000000000000000000000000000000000000..6c6959332625648f1aa3d5156ab12e7cc4c2e075
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/parameter_array_section_1.f90
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! Tests the fix for PR29821, which was due to failure to simplify the
+! array section, since the section is not constant, provoking failure
+! to resolve the argument of SUM and therefore to resolve SUM itself.
+!
+! Contributed by Harald Anlauf  <anlauf@gmx.de>
+!
+module gfcbug45
+  implicit none
+contains
+  subroutine foo 
+    real, external :: mysum
+    integer :: i
+    real    :: a
+    real, parameter :: eps(2) = (/ 1, 99 /)
+    i = 1
+    a = sum (eps(i:i+1) * eps)
+    print *, a
+  end subroutine foo
+end module gfcbug45
+  use gfcbug45
+  call foo
+end
+! { dg-final { cleanup-modules "gfcbug45" } }