c - Ensuring const safety -
is there way ensure const safety when dealing constant data?
i mean, there way prevent kind of code?
const int a; int* p = (int*)&a; *p = 0;
there absolutely no way prevent kind of code showing. cast re-interprets pointer, letting caller whatever pleases. result, program gets undefined behavior, , may crash. unfortunately, not always crash, , on platforms never crash.
Comments
Post a Comment