This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82900] Warn on initialization with self
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Nov 2017 16:34:42 +0000
- Subject: [Bug c++/82900] Warn on initialization with self
- Auto-submitted: auto-generated
- References: <bug-82900-4@http.gcc.gnu.org/bugzilla/>
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 ***