This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29117] Copy constructor is called with "this == &rhs"
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Oct 2006 04:24:14 -0000
- Subject: [Bug c++/29117] Copy constructor is called with "this == &rhs"
- References: <bug-29117-13267@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from bangerth at dealii dot org 2006-10-10 04:24 -------
Your expectations are wrong. You probably believe that here
-------------
void f3()
{
D d3;
printf("3) getValue() -> %d, ", d3.getValue());
{
D d3 = d3;
printf("getValue() -> %d\n", d3.getValue());
}
}
------------------
the initialization of the inner d3 should happen with the outer d3, but
that isn't so: in the initialization clause, the outer d3 is already no
longer visible. You therefore initialize a variable with itself. This is
a documented way to generate uninitialized variables and at the same time
circumvent the warning that would usually results from this action.
There is a warning -Winit-self in more recent releases that warns about this
specific case. Now, of course the fact that it doesn't trigger on this code
is not very helpful. Have to investigate this...
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29117