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++/82900] Warn on initialization with self


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82900

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=48483
         Resolution|---                         |DUPLICATE

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
I believe this bug is a dupe of pr52167.  See also pr48483 for a
similar/related request.

As an aside, the test case in comment #1 is fine (as in has well-defined
semantics) because there is no access to the yet-uninitialized object. 
Changing the test case so that the copy ctor accesses the argument and
compiling it with optimization does produce a warning:

$ cat t.C && gcc -O2 -S -Wall -Wextra t.C
struct Y { int i; Y (Y &y): i (y.i) { } };

int main() {
  Y y(y);
}
t.C: In function ‘int main()’:
t.C:4:5: warning: ‘y.Y::i’ is used uninitialized in this function
[-Wuninitialized]
   Y y(y);
     ^

*** This bug has been marked as a duplicate of bug 52167 ***

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