As I try to apply const-correctness for my own code, I often have to add const
qualifications to function definitions in other modules (written by other programmers) in order to use those functions in my own code. (see here on back-patching const-correctness)
I always thought that if everything compiles fine, this could impossibly lead to broken functionality as const
labels only matter at compile time.
Yet, the other day one of my colleagues insisted that I should rerun all automated tests before I commit code with added const
labels, where I thought it was sufficient that such code compiled.
Does he have a point? Is there a way that applying const-correctness could break existing functionality ?
Edit: It is maybe important to note that, generally, I only have to do this for pointer parameters of functions (e.g. Something getSomething(Object* pObj)
to Something getSomething(const Object* pObj)
. I do not change return types or method constness as this is not a problem for client code.