I know that the following is explicitly allowed in the standard:
int n = 0; char *ptr = (char *) &n; cout << *ptr;
What about this?>
*ptr = 0;
writes to an int, so it is an access to int, with an lvalue of type int, so that part of the code is fine.
The cast is morally fine, but the C/C++ standard texts don't clearly describe casts, or pointers, or anything fundamental.