The following is a foo function that take a constant pointer:
void foo(int *const x);
If you point x to another adress inside foo function, it will not compiled.
The author seems think that
void foo(cont int *x);
is function that takes a constant pointer which is wrong, it is a function that takes pointer to constant object. In this case, it is legal if you point x to another address in memory inside foo function.
Where do you see this confusion? I don't think it's there.
The author points out that it is not necessarily undefined behavior to take your second prototype, cast the const away and modify the pointed-to object if you ensure that it is only called with non-constant objects.
> The function foo takes a const pointer, which is a promise from the author of foo that it won’t modify the value of x. Given this information, it would seem the compiler may assume x is always zero, and therefore y is always zero.
The author does not think that, all he does is point out correctly that const-qualifying a pointer's target type cannot be used for optimization purposes as it does not make any actual guarantees about object mutability.
Note that in contrast, restrict-qualifying a ponter-to-const (ie `const int *restrict x`) does make such guarantees, but only callee-side.
The author seems think that
is function that takes a constant pointer which is wrong, it is a function that takes pointer to constant object. In this case, it is legal if you point x to another address in memory inside foo function.