This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR tree-optimization/43904: Wrong code with -foptimize-sibling-calls and memcpy on x86_64


Hi,

PR 43904 is a dup of PR 43572. I am checking in the run-time testcase
for PR 43904.


H.J.
---
Index: gcc.dg/tree-ssa/tailcall-6.c
===================================================================
--- gcc.dg/tree-ssa/tailcall-6.c	(revision 0)
+++ gcc.dg/tree-ssa/tailcall-6.c	(revision 0)
@@ -0,0 +1,33 @@
+/* PR tree-optimization/43904.  */
+/* { dg-do run } */
+/* { dg-options "-O1 -foptimize-sibling-calls" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern void abort(void);
+
+void *memcpy(void *dest, const void *src, size_t n);
+
+void
+buggy_init(void *ptr, size_t size)
+{
+  const char *str = "Hello world!";
+  memcpy(ptr, &str, size);
+}
+
+void
+expose_bug(void *ptr, size_t size)
+{
+  const char *str;
+  memcpy(&str, ptr, size);
+  if (*str != 'H')
+    abort ();
+}
+
+int
+main()
+{
+  const char *ptr;
+  buggy_init(&ptr, sizeof(ptr));
+  expose_bug(&ptr, sizeof(ptr));
+  return 0;
+}
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 158752)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2010-04-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR tree-optimization/43904
+	* gcc.dg/tree-ssa/tailcall-6.c: New.
+
 2010-04-26  Iain Sandoe  <iain.sandoe@sandoe-acoustics.co.uk>
 
 	PR testsuite/35165


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]