diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d00143afc385e37a9dfe23a33970dadc65ee7700..91874635b8b3c0facea1940cf2b4d1f85dc17cde 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-17  Andrew MacLeod  <amacleod@redhat.com>
+
+	PR tree-optimization/34648
+	* tree-ssa-sccvn.c (visit_use): Expressions which can throw are varying.
+
 2008-01-17  Anatoly Sokolov <aesok@post.ru>
 
 	* config/avr/avr.h (LINK_SPEC): Support -mrelax and -mpmem-wrap-around.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3a460685243b8de44a5cf663510aacba00a8aa90..eb8a26cf610f15ac886e902e6c70b2004b52ad63 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-17  Andrew MacLeod  <amacleod@redhat.com>
+
+	PR tree-optimization/34648
+	* gcc.c-torture/compile/pr34648.c: New testcase.
+
 2008-01-17  Sebastian Pop  <sebastian.pop@amd.com>
 
 	PR testsuite/34821
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34648.c b/gcc/testsuite/gcc.c-torture/compile/pr34648.c
new file mode 100644
index 0000000000000000000000000000000000000000..1f7472fe76deb5b7e21d6925e1a8d0fcd55b9a4d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr34648.c
@@ -0,0 +1,39 @@
+/* PR tree-optimization/34648 */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fexceptions" } */
+
+extern const unsigned short int **bar (void) __attribute__ ((const));
+const char *a;
+int b;
+char c;
+
+char
+foo (int *x)
+{
+  char r;
+
+  c = '\0';
+  if (!b)
+    {
+      while (((*bar ())[a[*x]] & 0x2000) != 0)
+        (*x)++;
+      if (a[++(*x)] == '-')
+        {
+          (*x)++;
+          if (a[*x] && !((*bar ())[a[*x]] & 0x2000))
+            return '?';
+        }
+      if (!a[*x] || ((*bar ())[a[*x]] & 0x2000))
+        {
+          while (((*bar ())[a[*x]] & 0x2000))
+            ++(*x);
+          return '\0';
+        }
+    }
+
+  r = a[*x];
+  b = a[*x] && !((*bar ())[a[*x]] & 0x2000);
+  return r;
+}
+
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 7f566dba8e1c417c71d401f1dd8d7a175e3eb1f8..d7b8c8a72d7fb990d1f24e868f787dd6a6953b6c 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1609,7 +1609,8 @@ visit_use (tree use)
 	  changed = visit_phi (stmt);
 	}
       else if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT
-	       || (ann && ann->has_volatile_ops))
+	       || (ann && ann->has_volatile_ops)
+	       || tree_could_throw_p (stmt))
 	{
 	  changed = defs_to_varying (stmt);
 	}