In this case it is safe because you're going from something that can be modified to a const context. It is the vice versa situation that can be unsafe, e.g., because it could lead to an attempt to modify a string constant.