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: "oschmidt at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Oct 2006 17:03:27 -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 #6 from oschmidt at gmx dot net 2006-10-12 17:03 -------
> You therefore initialize a variable with itself. This is
> a documented way to generate uninitialized variables and
> Here's the right combination of flags that warns (for f3() only):
Thank you for your answer, this is very interesting (but where is it
documented?).
But still *very* dangerous, because the destructor of this unitialized object
is called and such the destructor is working with some random memory.
So a compiler warning for this makes really sense not only for f3() but also
for f4().
BTW: I found that the IBM-C++ Compiler for MVS has similar behaviour, so it
really might be a feature and not a bug, althoug a very strange feature.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29117