summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/init/copy7.C
blob: 20e1e47dbb9476e561438d71cbf6a1094bfb5fb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 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);
}