Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you have a `const int i` then the compiler can assume that i never changes.

Plus, you can’t even compile your code if you try to modify a const variable.



This isn't guaranteed: Modification after const cast on a const variable is ill formed but the compiler is not required to diagnose it - an generally it can't because it doesn't know what your reference/pointer points to.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: