4 ms·
Yes, but it can't assume any random function call it does doesn't use a different pointer to the same object which is not const. So, even if you don't cast cons
by alexlarsson 7y ago
Yes, but it can't assume any random function call it does doesn't use a different pointer to the same object which is not const. So, even if you don't cast const to non-const pointers you can run into the const value changing.
- bstamour 7y agoConcrete example: void foo(const int* const p1, int* const p2) { int a = *p1; *p2 += 42; int b = *p1; return a == b; // b = a + 42 } int main() { int x = 0; return foo(&x, &x); }