Always initialize your variables in C. It prevents a whole class of security and stability bugs. uid_t callerUID = 0; NO NO NO NO NO N—
-
-
It also prevents the compiler from issuing a warning when you subsequently fail to fill in a meaningful value.
1 reply 1 retweet 4 likes -
Unconventional opinion: unless there's a default value that's semantically correct, variables should never be initalized. Let -W* work.
2 replies 2 retweets 8 likes -
Replying to @RichFelker @thegrugq
Non-portable (compiler warnings are not standard) and imperfect (compiler doesn’t always know if a variable gets initialized so can’t warn.)
2 replies 0 retweets 0 likes -
Your development process doesn't have to be portable. It just has to warn you while you're developing.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @thegrugq
C does not allow for a perfect warning system. For instance is x or y initialized here? int x, y; scanf("%x + %x", &x, &y);
1 reply 0 retweets 1 like -
Depends on return value of scanf. If you don't check it, code is unsafe. Static analysis can verify you checked right.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @thegrugq
This hypothetical compiler seems to be pretty perfect. C ad petitio principii sounds lovely but is not a real-world development environment.
2 replies 0 retweets 0 likes
This "hypothetical compiler" is clang or modern gcc.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.