This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: copy-assignment of array type with trivial ctor



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]