In C++ I have a function that only requires read-only access to an array but is mistakenly declared as receiving a non-const pointer:
size_t countZeroes( int
The problem of const_cast is always the same -- it allows you to "break the rules", just like casting to and from void* -- sure you can do that, but the question is why should you?
In this case it's of course ok, but you should ask yourself why didn't you declare size_t countZeroes( const int* array, size_t count ) in the first place?
And as a general rule about const_cast: