This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: copy-assignment of array type with trivial ctor
- From: "Brian R. Gaeke" <brg at sartre dot dgate dot ORG>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 18 May 2002 03:19:33 -0700
- Subject: Re: copy-assignment of array type with trivial ctor
- References: <or7km4r8a8.fsf@free.redhat.lsd.ic.unicamp.br>
> This patch fixes the problem. If anyone could code up a testcase
> based on the description above, so that we avoid any risks by basing
> our test on the testcase I got from this customer, I'd be forever
> grateful. It could be a link test, should the copy assignment
> operator not be defined, or it could test for run-time side-effects of
> the copy assignment operator. Thanks in advance,
A testcase is attached.
--
Brian R. Gaeke, brg@dgate.org -- GnuPG encrypted mail gleefully accepted
------------------------------------------------------------------------------
// test that A's copy assignment method is called
// when B's instance member array of A is assigned
// contributed by Brian Gaeke, public domain
// { dg-do run }
int status = 1;
class A { public: int i; A &operator =(const A &i) { status = 0; } };
class B { public: A arr[10]; };
int main (int argc, char **argv) {
B b;
b.arr[0].i = 15;
B a; a = b; // trigger copy assignment
return status;
}