Most will know that C++ mangles external names in a compiler specific way such that they encode the types of function parameters and the nesting of
namespaces. People are probably less aware that most C compilers also mangle some names to make them unique inside compilation units.
Continue reading “Name mangling in C”
C defines different types of behavior for certain features:
- deterministic behavior, most features such as the
- unspecified behavior, where the compiler has a choice on how to implement a feature, e.g the evaluation order of subexpressions. Here, I also include “needs not to” behavior, where it seems that it has been forgotten to mention this explicitly, e.g if two
const qualified compound literals of the same scope with the same value are folded into one object
- implementation defined behavior, behavior unspecified by the standard but for which an implementation has to document its choices, e.g the greatest value of an
- undefined behavior, the compiler is allowed to eat your hard disk for breakfast, such as when accessing an array element out of bounds
Towards its end, the C standard has long list for the later three types.
Where most C programmers will know about the possible pitfalls of undefined behavior, it seems that unspecified behavior has a lot less attention although it might have severe consequences, too.
Continue reading “non-deterministic programs through unspecified behavior”