[Bug c++/29117] Copy constructor is called with "this == &rhs"
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Thu Oct 12 19:55:00 GMT 2006
------- 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
More information about the Gcc-bugs
mailing list