]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/47541 (For integer pointers, the value of ++*p is not writte...
authorRichard Guenther <rguenther@suse.de>
Tue, 1 Feb 2011 11:27:04 +0000 (11:27 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 1 Feb 2011 11:27:04 +0000 (11:27 +0000)
2011-02-01  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/47541
* tree-ssa-structalias.c (push_fields_onto_fieldstack): Make
sure to have a field at offset zero.

* g++.dg/torture/pr47541.C: New testcase.

From-SVN: r169472

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr47541.C [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 88a7186151671548087ad96c9a4077b8b0d41337..27c16ea23b5c6a0e73bcb26f29c5d5396001a671 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-01  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47541
+       * tree-ssa-structalias.c (push_fields_onto_fieldstack): Make
+       sure to have a field at offset zero.
+
 2011-01-31  Nathan Froyd  <froydnj@codesourcery.com>
 
        Backport from mainline:
index 0579a449efad57077f3420e9af88ac3453d6cb3d..d8707ade4b75f4f58ad5d0209138d6a26f815920 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-01  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47541
+       * g++.dg/torture/pr47541.C: New testcase.
+
 2011-01-31  Nathan Froyd  <froydnj@codesourcery.com>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/torture/pr47541.C b/gcc/testsuite/g++.dg/torture/pr47541.C
new file mode 100644 (file)
index 0000000..350a051
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+
+struct Dummy {};
+struct RefCount : public Dummy {
+    ~RefCount(); /* Has to be non-pod.  */
+    int *a;
+    int *b;
+};
+RefCount::~RefCount(){}
+struct Wrapper : public Dummy { RefCount ref; };
+void __attribute__((noinline,noclone))
+Push(Wrapper ptr)
+{
+  *ptr.ref.b = 0;
+}
+extern "C" void abort (void);
+int main()
+{
+  int a = 1, b = 1;
+  Wrapper x;
+  x.ref.a = &a;
+  x.ref.b = &b;
+  Push(x);
+  if (b != 0)
+    abort ();
+  return 0;
+}
index 314705ccbfd13d7a9134bbd9def796423b42b92d..6716be7bdf2e9b6f0846bbe663b900f874f2cfd9 100644 (file)
@@ -4309,6 +4309,17 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
            if (!VEC_empty (fieldoff_s, *fieldstack))
              pair = VEC_last (fieldoff_s, *fieldstack);
 
+           if (!pair
+               && offset + foff != 0)
+             {
+               pair = VEC_safe_push (fieldoff_s, heap, *fieldstack, NULL);
+               pair->offset = 0;
+               pair->size = offset + foff;
+               pair->has_unknown_size = false;
+               pair->may_have_pointers = false;
+               pair->only_restrict_pointers = false;
+             }
+
            if (!DECL_SIZE (field)
                || !host_integerp (DECL_SIZE (field), 1))
              has_unknown_size = true;