c++ - uninitialized local variable 'a' used by VS2012 on the object of a template class -


in vs2012, below code doesn't compile, says error c4700: uninitialized local variable 'a' used on line a<int> b(a); tested in gcc4.4.7, it's fine.

i had thought prevents compiler generate default constructor, seems issue vs2012. why give error, explanation on how compiler process code?

template<typename t> class { public:     t* p; };  int main() {     a<int> a;     a<int> b(a); } 

i tested in gcc4.4.7, it's fine.

in sense think it's fine? never setting value a.p code may compile, it's still garbage data gcc.

by default, c4700 warning, not error can compile in same broken way gcc compiles it. have /wx set treat warnings errors, practice.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -