This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20142] implicity assignment with multi-dimensionnal array members
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Feb 2005 17:56:56 -0000
- Subject: [Bug c++/20142] implicity assignment with multi-dimensionnal array members
- References: <20050222133332.20142.bernard.maudry@topgraphx.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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