This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37854] No error when creating a variable from itself
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Oct 2008 19:08:08 -0000
- Subject: [Bug c++/37854] No error when creating a variable from itself
- References: <bug-37854-16841@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from pinskia at gcc dot gnu dot org 2008-10-16 19:08 -------
In this case since x and y are empty structs there are no real uses of them.
If I change the code to:
struct X {int i;};
int main()
{
int i = i;
X x = x;
X y(y);
return i+x.i+y.i;
}
--- CUT ---
And turn on optimization, I get the following warnings:
t.c: In function 'int main()':
t.c:5: warning: 'i' is used uninitialized in this function
t.c:8: warning: 'x.X::i' is used uninitialized in this function
t.c:8: warning: 'y.X::i' is used uninitialized in this function
Note all of the above warnings should only happen with -Winit-self (which works
correctly with the C front-end and is PR 34772 ).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37854