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.



Core for a Sobolev space
(Too long for a comment.)


I have just learned that my colleagues, Bartłomiej Dyda and Michał Kijaczko, wrote a paper [1] on that particular problem for *fractional* Sobolev spaces. In their work, they cite Theorem 3.25 in McLean's book [2], which reads as follows (with the original notation):


**Theorem:** *For any open set $\Omega$ and any real $s \geqslant 0$, the set $W^s(\Omega) \cap \mathcal E(\Omega)$ is dense in $W^s(\Omega)$.*


So at least smooth functions in $\Omega$ are always dense in $W^s(\Omega)$ (but of course they need not extend smoothly to the boundary).


I did not have time to check carefully the two references mentioned above for an answer to your question — perhaps it is written somewhere in [2].


References:


* [1] B. Dyda, M. Kijaczko, *On density of smooth functions in weighted fractional Sobolev spaces*, Nonlinear Anal. 205 (2021): 112231, [DOI:10.1016/j.na.2020.112231](https://doi.org/10.1016/j.na.2020.112231), [arXiv:2009.00077](https://arxiv.org/abs/2009.00077)
* [2] W. McLean, *Strongly elliptic systems and boundary integral equations*. Cambridge University Press, Cambridge, 2000.


