Compiler not detecting obviously uninitialized variable

前端 未结 4 1066
一整个雨季
一整个雨季 2020-12-01 11:50

All C compilers I\'ve tried won\'t detect uninitialized variables in the code snippet below. Yet the case is obvious here.

Don\'t bother about the functionality of t

4条回答
  •  隐瞒了意图╮
    2020-12-01 12:08

    Michael, I don't know which version of Visual Studio 2013 you tried this on, but it is most certainly outdated. Visual Studio 2013 Update 4 correctly produces the following error message on the first use of totaldiff:

    error C4700: uninitialized local variable 'totaldiff' used
    

    You should consider updating your work environment.

    By the way, here is what I see directly in the editor:

    Visual Studio 2013 caught the error

提交回复
热议问题