<b>(a) </b> void f(int* p) { for (int i = 0; i < 10; ++i) { g(p); h(*p); } } <b></b> (b) void f(int* p) { int x = *p; for (int i = 0; i < 10; ++i) { g(p); h(x); } }
Example 5: Avoiding aliasing problems. (a) Obvious implementation; (b) version that tells the compiler that g does not modify *p.