2 ms·
But this means the vast majority of C code isn't portable since you can't know what it will do with a given platform and compiler combination and the presence o
by imtringued 4y ago
But this means the vast majority of C code isn't portable since you can't know what it will do with a given platform and compiler combination and the presence of even a single line of UBI invalidates the whole program.
It basically means that the whole portability argument that is supposed to be in favor of C is just wrong because every compiler and platform actually brings its own C dialect and it is just sheer coincidence that it works at all.
- AlotOfReading 4y agoYes. The nominal reality is that effectively all extant C code has undefined behavior, but the practical reality is that most of that code will work portably as long as some reasonable precautions are taken.
- Karellen 4y agoAre you seriously suggesting that the vast majority of C code causes signed int overflows or dereferences invalid pointers? Not sure about the C code bases you've been spending time in, but in the ones I've looked at, the overwhelming majority of the code has been well-defined by either the C standard or the implementation. In the cases where it hasn't, the vast majority of those cases were genuine bugs that needed fixing, and the fix made the code well-defined. The number of codebases I've seen that actually relied on unspecified behaviour, or on whatever the current compiler/OS/CPU happened to do with undefined behaviour, is miniscule. (Or an entry in an obfuscated/underhanded coding contest.)