Dimensional-reduction anomaly in spherically symmetric spacetimes