The const declaration only indicates how an identifier will be used within the 范围 of its declaration; it does not say that the underlying object can not change.
例如:
int foo(const int *p) {
int x = *p;
bar(x);
x = *p;
return x;
}
编译器不能假设对 bar()的调用没有修改 *p,因为 p可能是指向全局 int 的指针,而 bar()可能会修改它。
If the compiler knows enough about the caller of foo() and the contents of bar() that it can prove bar() does not modify *p, then 它也可以在不使用 const 声明的情况下执行该证明.