I have a pointer int* p
, and do some operations in a loop. I do not modify the memory, just read. If I add const
to the pointer (both cases, const int* p
, and int* const p
), can it help a compiler to optimize the code?
I know other merits of const
, like safety or self-documentation, I ask about this particular case. Rephrasing the question: can const
give the compiler any useful (for optimization) information, ever?