* tree-ssa.c (useless_type_conversion_p_1): Return
false if inner_type is incomplete and outer_type is complete.
* gcc.c-torture/compile/pr38505.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142806
138bc75d-0d04-0410-961f-
82ee72b054a4
+2008-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/38505
+ * tree-ssa.c (useless_type_conversion_p_1): Return
+ false if inner_type is incomplete and outer_type is complete.
+
2008-12-17 Sebastian Pop <sebastian.pop@amd.com>
* doc/install.texi (Prerequisites): Document PPL and CLooG-PPL
+2008-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/38505
+ * gcc.c-torture/compile/pr38505.c: New test.
+
2008-12-17 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/auto6.C: Test more stuff.
--- /dev/null
+/* PR middle-end/38505 */
+/* { dg-do compile } */
+
+struct S
+{
+ unsigned short a[50];
+ unsigned short b[20];
+};
+extern void bar (struct S *);
+extern void baz (unsigned short *);
+extern unsigned short d[];
+
+void
+foo (void)
+{
+ struct S s;
+ unsigned short g[50];
+
+ baz (g);
+ __builtin_memcpy (&s, g, sizeof (g));
+ __builtin_memcpy (s.b, d, sizeof (s.b));
+ bar (&s);
+}
if (TREE_CODE (inner_type) != TREE_CODE (outer_type))
return false;
+ /* Conversion from an incomplete to a complete type is never
+ useless. */
+ if (!COMPLETE_TYPE_P (inner_type) && COMPLETE_TYPE_P (outer_type))
+ return false;
+
/* ??? This seems to be necessary even for aggregates that don't
have TYPE_STRUCTURAL_EQUALITY_P set. */