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: 12 Oct 2006 19:55:43 -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 #8 from bangerth at dealii dot org 2006-10-12 19:55 -------
(In reply to comment #6)
> Thank you for your answer, this is very interesting (but where is it
> documented?).
In the gcc manual.
> But still *very* dangerous, because the destructor of this unitialized object
> is called and such the destructor is working with some random memory.
Yes. You get what you deserve. The compiler warns you about that, if you
ignore this, then you shouldn't expect anything good to come out of it.
> So a compiler warning for this makes really sense not only for f3() but also
> for f4().
It does:
g/x> /home/bangerth/bin/x86_64/gcc-4.0.2/bin/c++ -Winit-self -Wuninitialized
-O2 -c x.cc
x.cc: In function 'void f4()':
x.cc:79: warning: 'd4$c$v' is used uninitialized in this function
x.cc: In function 'void f3()':
x.cc:69: warning: 'd3$c$v' is used uninitialized in this function
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29117