diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c4bf6203e78cecf5c3986a70e28f27e14e10127f..cfa16d3e2e6b5456227aa0107621eca308e00063 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-11-29  Alexandre Oliva  <aoliva@redhat.com>
+
+	PR debug/46338
+	* g++.dg/debug/pr46338.C: New.
+
 2010-11-29  Richard Guenther  <rguenther@suse.de>
 	    Zdenek Dvorak  <rakdver@kam.uniff.cz>
 
diff --git a/gcc/testsuite/g++.dg/debug/pr46338.C b/gcc/testsuite/g++.dg/debug/pr46338.C
new file mode 100644
index 0000000000000000000000000000000000000000..dfa92452da1a67d08778362f06d0d23a26fb1c06
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr46338.C
@@ -0,0 +1,24 @@
+// PR debug/46338
+// { dg-do compile }
+// { dg-options "-O -fprofile-generate -fcompare-debug" }
+
+void bar ();
+
+struct S
+{
+  int f ()
+  {
+  }
+};
+
+S *s;
+
+void
+foo (int x)
+{
+  if (x)
+    return;
+  bar ();
+  for (int j = 0; j < s->f (); j++)
+    ;
+}