[Bug c++/37854] No error when creating a variable from itself
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Oct 16 19:09:00 GMT 2008
------- 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
More information about the Gcc-bugs
mailing list