public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove "bogus" g++.dg/init/copy7.C testcase
@ 2011-08-15 12:43 Richard Guenther
  2011-08-15 16:45 ` Mike Stump
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Guenther @ 2011-08-15 12:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: gcc


The g++.dg/init/copy7.C testcase checks whether the C++ frontend
guards memcpy it emits via a conditional verifying that src != dst
because calling memcpy with overlapping source / destination is
not supported.

The testcase is misguided though (and the C++ frontend was, until
recently) - the middle-end itself will replace aggregate copies
with memcpy libcalls if it suits - without such conditional.
As PR39480 shows (the bug that prompted to "fixing" the C++ frontend),
the "error" was diagnosed by valgrind, not any real memcpy implemenation.

The argument still holds that no reasonable memcpy implementation
will reject the src == dest case.  Arguing about explicit cache
write-allocation is moot, as you'd still have to handle the
case of memcpy (&a, &a+1, 1) correctly - and thus any reasonable
implementation would handle the src == dest case explicitly if
that is necessary.

Thus, the following simply removes the now FAILing testcase on
the basis that it never was PASSing really (as my modified
C testcases in PR50079 show).  If we ever encounter a platform
that fails for memcpy (&a, &a, ...) and we decide it's not the
platform that is broken we have to invent a fix in the middle-end
and (conditionally) guard any libcall block moves.

Comments?  Ok to commit?

Thanks,
Richard.

2011-08-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/50079
	* g++.dg/init/copy7.C: Remove testcase.

Index: gcc/testsuite/g++.dg/init/copy7.C
===================================================================
--- gcc/testsuite/g++.dg/init/copy7.C	(revision 177759)
+++ gcc/testsuite/g++.dg/init/copy7.C	(working copy)
@@ -1,39 +0,0 @@
-// PR c++/39480
-// It isn't always safe to call memcpy with identical arguments.
-// { dg-do run }
-
-extern "C" void abort();
-extern "C" void *
-memcpy(void *dest, void *src, __SIZE_TYPE__ n)
-{
-  if (dest == src)
-    abort();
-  else
-    {
-      __SIZE_TYPE__ i;
-      for (i = 0; i < n; i++)
-        ((char *)dest)[i] = ((const char*)src)[i];
-    }
-}
-
-struct A
-{
-  double d[10];
-};
-
-struct B: public A
-{
-  char bc;
-};
-
-B b;
-
-void f(B *a1, B* a2)
-{
-  *a1 = *a2;
-}
-
-int main()
-{
-  f(&b,&b);
-}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Remove "bogus" g++.dg/init/copy7.C testcase
  2011-08-15 12:43 [PATCH] Remove "bogus" g++.dg/init/copy7.C testcase Richard Guenther
@ 2011-08-15 16:45 ` Mike Stump
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Stump @ 2011-08-15 16:45 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches, gcc

On Aug 15, 2011, at 5:42 AM, Richard Guenther wrote:
> The argument still holds that no reasonable memcpy implementation
> will reject the src == dest case.

Hum...  Sounds like if that's the case that we should document it in the manual as something we expect (requirement) of the memcpy implementation.  I'll let a frontend or optimization person review this.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-15 16:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-15 12:43 [PATCH] Remove "bogus" g++.dg/init/copy7.C testcase Richard Guenther
2011-08-15 16:45 ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).