The gap phenomenon in Riemannian geometry