This is the mail archive of the 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 #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", d3.getValue());
the initialization of the inner d3 should happen with the outer d3, but
that isn't so: in the initialization clause, the outer d3 is already no
longer visible. You therefore initialize a variable with itself. This is
a documented way to generate uninitialized variables and at the same time 
circumvent the warning that would usually results from this action.

There is a warning -Winit-self in more recent releases that warns about this
specific case. Now, of course the fact that it doesn't trigger on this code
is not very helpful. Have to investigate this...



bangerth at dealii dot org changed:

           What    |Removed                     |Added
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

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