a) The first line is equivalent to static_cast<char**>(const_cast<void*>(arg))
, I believe. Not that it makes any difference.
b) Well, it is legal if arg actually does point to an array of char*. If one reinterpret_cast
s a T* pointer to U* pointer (for arbitrary types T and U, related or otherwise) and back to T*, one is guaranteed to get the original value back. So yes, one can construct an example where this code would work. It doesn't mean the function is well designed, of course.