This is why one pre-fills BSS with 0x00, for example: so uninitialised variables don't bite you. A perfect programmer would not need the pre-fill. And anyway you don't get the pre-fill on vars declared on the stack.
What do you mean? That is just how the language is defined.
A perfect programmer writes good code in the boundaries set by the language definition.
I won't repeat explanations from other members or from me, you seem quite waterproof to any argument
If you don't like C, there are so many usable languages that the only problem is the time to try them all, some is also good.
Standard Pascal does not even have shift operators, but all compilers support them, so implementations might differ.
I would suggest you try Rust, which has well defined behaviour for all shift cases.
When the shift
generates an overflow, the program by default will panic (abort), unless you explicitly ask the compiler not to care for overflows.
Moreover, shift operation are well defined both for signed and unsigned types, another difference with C where right shifting a negative (signed, of course) integer is implementation defined.
Implementation defined means that the compiler can do what it wants, but it
must be documented; as opposed to UB, a program which includes IDB is compliant, though not strictly compliant.
But really, do read the rationale and learn the standard (C11 is nice, C17 does not change much and C2x is still in the making), if you don't want to get caught in the many pitfalls C admittedly has. Coding by expectations is going to bite you.
I highly recommend using static analysis tools when you can.
This.
Cppcheck is good,
clang-analyzer is also very good and FOSS, and Ericsson has built a FOSS driver for both to facilitate their use for CI and large projects (with multi file checking) and to store results in a database, called
CodeChecker.
EtA: I re-checked, and CodeChecker will not run cppcheck (only clang-analyzer and clang-tidy), but is capable to ingest and store cppcheck reports, together
with many other formats