--- 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
--- Comment #7 from oschmidt at gmx dot net 2006-10-12 17:10 ---
So a compiler warning for this makes really sense
not only for f3() but also for f4().
So I think it would be a good idea to reopen this bug report. It is then not a
bug report about inproper compiler behaviour but a bug
--- 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
--- Comment #4 from bangerth at dealii dot org 2006-10-10 04:24 ---
Your expectations are wrong. You probably believe that here
-
void f3()
{
D d3;
printf(3) getValue() - %d,, d3.getValue());
{
D d3 = d3;
printf(getValue() - %d\n,
--- Comment #5 from bangerth at dealii dot org 2006-10-10 04:27 ---
Here's the right combination of flags that warns (for f3() only):
g/x /home/bangerth/bin/gcc-4.2-pre/bin/c++ -Winit-self -Wuninitialized -O2 -c
x.cc
x.cc: In function #8216;void f3()#8217;:
x.cc:42: warning:
--- Comment #2 from oschmidt at gmx dot net 2006-09-18 08:35 ---
default operator= with lhs and rhs as the same.
if it would be the operator= this would be ok. But it's the default copy
constructor that is called withed lhs and rhs the same and such an object with
undefined content is
--- Comment #3 from oschmidt at gmx dot net 2006-09-18 08:47 ---
So which version do you think have a bug?
I don't know which behaviour should be correct C++, but I think it is
dangerous
that an object with undefined content is constructed without even a compiler
warning.
I
--- Comment #1 from pinskia at gcc dot gnu dot org 2006-09-17 18:51 ---
Well d2, we call the default operator= with lhs and rhs as the same.
So which version do you think have a bug?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29117