Do you have any C++ question? I will try to answer it.
AFAIU it isn't UB for p->blub to change across inside of compute_something(). Unless I get the compiler to see that p was allocated const (e.g. const sometype st = ...; foo(&st);) C++ doesn't allow to make the assumption on its own.
-
-
Even if allocated const the compiler often won't see that (cross TU, too many layers). Also, often it's not actually desirable to have the value be constant for the whole lifetime. It's just for a region of code. Unless I copy the value I cannot make C[++] recognize that.
-
Ok, thank you for the example. In this case you can't tell C++ it won't change. The best way is to change your code, so it won't use globals. And if it's member function, you should mark it const.
- 8 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.