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

Popular posts from this blog

php - Magento - Deleted Base url key -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -