This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/29117] Copy constructor is called with "this == &rhs"



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]