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++/37854] No error when creating a variable from itself



------- 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


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