class A{
const size_t number;
public:
A(size_t number): number(number) {}
void f(){
//read number, possibly save in CPU register
//call a function that the compiler can't inspect
// so it should assume that anything in the program state changed
//read number again
}
在那里,它number
再次读取,编译器(如果优化已开启)是否仍会假设它不能更改,因为它是const
,因此从 CPU 寄存器中读取标志,如果它之前放置在其中之一中?