--- gcc/tree.c.jj	2012-10-19 11:01:07.000000000 +0200
+++ gcc/tree.c	2012-10-23 14:46:24.846195605 +0200
@@ -8467,14 +8467,21 @@ variably_modified_type_p (tree type, tre
   tree t;
 
 /* Test if T is either variable (if FN is zero) or an expression containing
-   a variable in FN.  */
+   a variable in FN.  If TYPE isn't gimplified, return true also if
+   gimplify_one_sizepos would gimplify the expression into a local
+   variable.  */
 #define RETURN_TRUE_IF_VAR(T)						\
   do { tree _t = (T);							\
     if (_t != NULL_TREE							\
 	&& _t != error_mark_node					\
 	&& TREE_CODE (_t) != INTEGER_CST				\
 	&& TREE_CODE (_t) != PLACEHOLDER_EXPR				\
-	&& (!fn || walk_tree (&_t, find_var_from_fn, fn, NULL)))	\
+	&& (!fn								\
+	    || (!TYPE_SIZES_GIMPLIFIED (type)				\
+		&& !TREE_CONSTANT (_t)					\
+		&& TREE_CODE (_t) != VAR_DECL				\
+		&& !CONTAINS_PLACEHOLDER_P (_t))			\
+	    || walk_tree (&_t, find_var_from_fn, fn, NULL)))		\
       return true;  } while (0)
 
   if (type == error_mark_node)
--- gcc/testsuite/g++.dg/debug/pr54828.C.jj	2012-10-23 14:30:13.194012566 +0200
+++ gcc/testsuite/g++.dg/debug/pr54828.C	2012-10-23 14:30:07.000000000 +0200
@@ -0,0 +1,14 @@
+// PR debug/54828
+// { dg-do compile }
+// { dg-options "-g" }
+
+struct T { T (); virtual ~T (); };
+struct S : public virtual T { S (); virtual ~S (); };
+int v;
+void foo (char *);
+
+S::S ()
+{
+  char s[v];
+  foo (s);
+}
