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

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -