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


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