------- Additional Comments From reichelt at gcc dot gnu dot org  2005-02-22 
17:56 -------
Here's a slightly reduced testcase.

===================================================
#include<stdio.h>

struct A
{
    A() : i() {}
    A (const A&);

    ~A()
    {
        printf ("Destructor: i = %d\n", i);
    }

    A& operator= (const A &a)
    {
        static int count=0;
        i = a.i + 1;
        printf ("Assignment %d\n", ++count);
        return *this;
    }

    int i;
};

struct B
{
    A x[2][2];
};

int main()
{
    B b;
    b = b;
}
===================================================

With versions prior to gcc 3.3 we get the output

  Assignment 1
  Assignment 2
  Assignment 3
  Assignment 4
  Destructor: i = 1
  Destructor: i = 1
  Destructor: i = 1
  Destructor: i = 1

With gcc 3.3 and later we get

  Destructor: i = 0
  Destructor: i = 0
  Destructor: i = 0
  Destructor: i = 0


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20142

Reply via email to