3 ms·
MSVC will very confidently warn on cases like this by default: int foo() { int bar; return bar + 5; /* C4700: local variable 'bar' used wit
by userbinator 11y ago
MSVC will very confidently warn on cases like this by default:
int foo() {
int bar;
return bar + 5; /* C4700: local variable 'bar' used without having been initialized */
}
https://msdn.microsoft.com/en-us/library/axhfhh6x.aspx https://msdn.microsoft.com/en-us/library/axhfhh6x.aspx
In the same situation, GCC says "may be used uninitialized in this function" if you enable the warning (-Wmaybe-uninitialized), despite this being a trivial and certain case.
- ydcvjk 11y agogcc 4.9.2 gives: warning: 'bar' is used uninitialized in this function Maybe you are using a old version. If you enable -Wall which you always should then this flag is automatically enabled. https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall-296 https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#inde...
- anon1385 11y ago-Wuninitialized has been broken in GCC for over a decade: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501
- bluecalm 11y agoWhile I like MSVC team approach to this I don't think it's necessarily worse to just warn as long as that warning consistently work. I mean, just add some warning options to your compiling script and you are good to go. I am getting this error from GCC very consistently and as good as compilation error in practice.