How many connected components for the intersection $S \cap GL_n(\mathbb R)$ where $S \subset M_n(\mathbb R)$ is a linear subspace?

Let $S \subset M_n(\mathbb R^n)$ be a linear subspace. Is there a way to determine how many connected components there are for $S \cap GL_n(\mathbb R)$? Let us assume the intersection is nonempty. $GL_n(\mathbb R)$ has two connected components. Does this intersection have two connected components or possibly more?


It may have more. Consider $S\subseteq M_2(\newcommand{\RR}{\mathbb{R}}\RR)=\newcommand{\set}[1]{\left\{{#1}\right\}}\set{\newcommand{\bmat}{\begin{pmatrix}}\newcommand{\emat}{\end{pmatrix}}\bmat a & b\\c&d\emat : a,b,c,d\in\RR}$ defined by the equations $a=d$, $b=c$. This gives a two dimensional subspace. $\det$ restricted to this subspace has the form $a^2-b^2$, so the intersection of the complement of $GL_2(\RR)$ with $S$ is two intersecting lines ($a=b$ and $a=-b$), which divides the plane into four pieces. Hence $S\cap GL_2(\RR)$ has four connected components in this case.

I have no ideas as to how to compute the number of connected components in general, however I thought this might be useful.