My searches have turned up blank on this question... There are plenty of discussions of how const
may be helpful in compiler optimization by signaling read-only access of a variable, but I can't find an answer to the question as posed in the title. I'm interested in the question because I want to avoid thinking about using const
for optimization if the compiler can do that anyway.
I appreciate that even if the compiler is able to find unchanging values and optimize them to read-only access, there will be cases where use of const
would still be helpful. I'm just looking for an answer on compiler capability in broad terms - does the GCC optimizer look for unchanging values without the use of const
?