Consider the bump function $f \in {\mathcal C}^\infty_c(]-1, 1[)$:
$$f(x) = \exp \left( \frac {1}{x^2-1} \right) $$
There is a canonical way to extend it so that the extension $\tilde f \in {\mathcal C}^\infty_c(\mathbb R)$.
In general,
the compactness of function support can always be preserved under extension.
Question. Why isn't this true also for the restriction?
Using the previous example, why isn't $ f \big\vert_{\left [-\frac 1 2 , \frac 1 2 \right ]} $ compactly supported? Isn't the interval $\left [- \frac 1 2, \frac 1 2 \right ]$ compact?