Let $D$ be a domain of $\mathbb{R}^d$. That is, $D$ is a connected open subset of $\mathbb{R}^d$. The first-order Sobolev space $W^{1,2}(D)$ on $D$ is defined by \begin{align*} W^{1,2}(D)=\{f \in L^2(D,m) \mid \partial f/\partial x_i \in L^2(D,m),\, 1\le i \le d\}. \end{align*} Here, $m$ is the Lebesgue measure and $ \partial f/\partial x_i$ is the distributional derivative of $f$.

It is well known that $W^{1,2}(D)$ becomes a Hilbert space. The norm is defined by $$\|f\|_{W^{1,2}(D)}:=\left[\int_{D}\{f(x)^2+\sum_{i=1}^d (\partial f/\partial x_i)^2\}\,m(dx) \right]^{1/2}.$$

When are smooth functions $C^\infty_{c}({\overline{D}})(=C^\infty_{c}(\mathbb{R}^d)|_{\overline{D}})$ dense in $W^{1,2}(D)$ ?

If there is a bounded linear operator $T\colon W^{1,2}(D) \to W^{1,2}(\mathbb{R}^d)$ such that $Tf=f$, $m$-a.e. on $D$, we can easily check that $C^\infty_{c}({\overline{D}})$ becomes a dense subspace of $W^{1,2}(D)$ (because $C^\infty_{c}(\mathbb{R}^d)$ is a dense subspace of $W^{1,2}(\mathbb{R}^d)$). Such an operator is called an extension operator, and it seems that its existence is known even when the boundary of $D$ is very complicated [for example, the Koch snowflake domain].

Can $C^\infty_{c}({\overline{D}})$ become dense in $W^{1,2}(D)$ without the extension operator?

I don't know such an example (of domains), so if anyone knows, please let me know.