We are minimising a convex function on a non-empty set defined by linear constraints (equalities and inequalities). $X^O$ is the set of all optimal solutions and we assume it is non-empty. Is it true that $X^O$ is a convex set?
I think it is not as for example in the case of the function $f(x)=x^2$ defined on $X=(-\infty, -1]\cup[1,\infty)$ we have got minimas at $x=-1$ and $x=1$, however, clearly this set is not convex. Am I right and is my example correct? Is such function defined in such a way convex?
The statement is true.
As mentioned in the comments, your example constraint set cannot be generated by an intersection of linear constraints. The intersection of linear constraints must be a convex set:
The minimizers of a convex function on a convex set are a convex set since the lower contour set of a convex function is convex.