Never lose sight of the fact that C is a portable language; he is expected to compile for various Operating Systems and Architectures, with minimal (or null) changes.
What happens if you compile a code that uses
const for an architecture that does not support memory protection? Any micro-controller falls into this category. Or the old MSDOS .
Although it is possible to control this circumstance by using pre-processor macros , the language, itself , has no way of controlling this. It is impossible to control where will end a variable. You can not even be sure that the automatic variables will end up in the stack, because of the simple fact that C does not have the stack concept. em> : you only have the concept of minimum lifetime of a variable. What you think is on the stack, can end anywhere: depends on the architecture . Why else would we have
<stdarg.h> ? For this reason, to abstract the concept of step-of-parameters .
It is for all the above that the modification of variables
const generates a undefined behavior : an architecture may allow it; Maybe an Operating System does not. A memory access error may be generated. Or maybe demons come out of your nostrils .