copy-assignment of array type with trivial ctor

Brian R. Gaeke brg@sartre.dgate.ORG
Sat May 18 03:23:00 GMT 2002


> 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;
}



More information about the Gcc-patches mailing list