/* constPointer.cpp --  Constant pointer arg/return */
const int * const w() {
  static int i;
  return &i;
}

int main() {
  const int *const ccip = w();     // OK
  const int *cip2 = w();           // OK:
                                   //  You would also expect that the compiler refuses
                                   //  to assign the return value of w( ) to a non-const
                                   //  pointer, and accepts a const int * const, but it
                                   //  might be a bit surprising to see that it also
                                   //  accepts a const int *, which is not an exact match
                                   //  to the return type. Once again, because the value
                                   //  (which is the address contained in the pointer) is
                                   //  being copied, the promise that the original variable
                                   //  is untouched is automatically kept. Thus, the second
                                   //  const in const int *const is only meaningful when
                                   //  you try to use it as an lvalue, in which case the
                                   //  compiler prevents you.
  return 0;
}
