Stability of an elastic bar with non-convex energy: discrete vs continuous