Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
bayindirh
on April 24, 2024
|
parent
|
context
|
favorite
| on:
The Performance Impact of C++'s `final` Keyword
> 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.
account42
on April 24, 2024
[–]
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:
Plus, you can’t even compile your code if you try to modify a const variable.