Comment by WalterBright

3 days ago

I tried:

    int test()
    {
        int i;
        return i;
    }

using clang on my Mac mini, and:

    clang -c test.c

and it compiled without complaint.

I always build with -Wall so I'm used to seeing the warning:

  > clang -Wall test.c
  test.c:4:16: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
      4 |         return i;
        |                ^
  test.c:3:14: note: initialize the variable 'i' to silence this warning
      3 |         int i;
        |              ^
        |               = 0
  1 warning generated.

For the oldest compiler I have access to, VC++ 6.0 from 1998:

  warning C4700: uninitialized local variable 'i' used

  • The trouble with warnings is every compiler has a different set of warnings. It balkanizes the language. Many D features are the result of cherry picking warnings from various compilers and making them standard features.

    • > It balkanizes the language.

      Not really, as C has had even more diverse implementations per-standardization. I would say the situation is now, much less diverse under the rule of GCC and Clang. (Yeah MSVC also exists.)

      6 replies →

C compilers without arguments start in 'trust me and shut up mode'. Seems to be sensible to me, because the 'I don't care about correctness' typically coincides with writing throwaway code, while you surely have the time to add compiler arguments when you set up the build system for an actual project.