Topological spaces in which a set is the support of a continuous function iff it is the closure of a open set. An exercise of Rudin's Real and Complex Analysis says:

Is it true that every compact subset of $\mathbf{R}^1$ is the support of a continuous function? If not, can you describe the class of all compact sets in $\mathbf{R}^1$ which are supports of continuous functions? Is your description valid in other topological spaces?

I proved that, in every metric space, a set (not necessarily compact) $A$ is the support of a continuous function if and only if it is the closure of an open set.
However, I don't think that this characterization holds for every topological space.
So, in order to find a counter-example, I tried to use the discrete and the trivial topologies. However, the discrete topology is metrizable and this characterization holds for topological spaces with the trivial topology.
Is this result true for any topological space? If not, what would be a counter-example?
 A: Here is a counter-example (compact and Hausdorff).
I will use ordinal topology (see e.g. first uncountable ordinal and Willard's General topology). Here's a crash-course:
The first uncountable ordinal is an uncountable totally ordered set $\omega_1$ with the property that all of its downsets $\left\{x\in\omega_1:x<\alpha\right\}$ (where $\alpha\in\omega_1$) are countable. Such a set exists and is unique up to order isomorphism.
The second uncountable ordinal is the set $\Omega=\omega_1\sqcup\{\omega_1\}$, the union of $\omega_1$ with a new point. It is also an ordered set with $\omega_1=\max\Omega$. With the order topology, $\Omega$ is a compact Hausdorff, non-second countable space. Every continuous function from $\Omega$ to any first-countable space is constant on a neighbourhood of $\omega_1$.

Let $X_1$ and $X_2$ be two copies of the second countable ordinal with maxima $x_1$ and $x_2$, respectively, and let $X$ be the space obtained by gluing $x_1$ and $x_2$ (i.e., the quotient of the disjoint union $\Omega\times\left\{1,2\right\}$ by identifying $(\omega_1,1)\sim(\omega_1,2)$).
Call the image of $x_i$ in $X$ just $x_0$. Then $X$ contains $X_1$ as a regular closed subset. the interior of $X_1$ is just $\left\{x\in X_1:x<x_0\right\}$, and $X_1$ is the closure of this set. Similarly for $X_2$.
However, $X_1$ is not the support of any continuous function $f\colon X\to \mathbb{R}$. Indeed, if $X_1$ were the support of $f$, then $f=0$ on $X\setminus X_1$, which is the interior of $X_2$, so $f=0$ on $X_2$ as well. In particular $f(x_0)=0$. However $f$ is constant on a neighbourhood of $x_0$, by general properties of the first uncountable ordinal (and because $\mathbb{R}$ is first countable). So the support of $f$ is strictly smaller than $X_1$, a contradiction.
A: I guess that given a subset $Y$ of a (topological) space $X$ by $Y$ is a support of a continuous function you mean that there exists a continuous function $f:X\to \Bbb R $ such that $Y=\overline{f^{-1}(\Bbb R\setminus\{0\} )}$. In particular, $Y$ is the closure of an open set. More precisely, $Y$ is the closure of a functionally open set (see [E, 1.5.13] below). So if $X$ is a normal space then  supports of continuous functions are exactly closures of open $F_\sigma$-subsets of $X$. Remark that by [E, 4.1.12] each open subset of a metric space is functionally open, which verifies your claim that for a metric space $X$, supports of continuous functions are exactly closures of open subsets of $X$. At last, in order to provide the required counterexample it suffices to find in a normal space $X$ and its subset $Y$ which is a closure of an open set (such sets are called regular closed sets), but not a closure of an $F_\sigma$-open set. 
References 
[E] Ryszard Engelking, General Topology,  2nd ed., Heldermann, Berlin, 1989.



A: As Ravsky wrote, in a normal space $X$, a set $E$ is the support of a continuous function if and only if $E$ is an open $F_\sigma$-set, and Luiz Cordeiro gave an example of a normal set $X$ and a compact set $X_1$ which is the closure of an open set, but is not $F_\sigma$, completing the answer. Moreover the claim
A set $E$ is the support of a continuous function if and only if $E$ is the closure of an open set
is true for perfectly normal spaces. If you allow less refined spaces, I found a pretty good example. Let $\mathbb{Q}$ be the rational numbers and $\mathbb{Q}^* $ its one point compactification (viz. $\mathbb{Q}^* = \mathbb{Q} \cup \{p\}$ for some element $p \notin \mathbb{Q}$ and the open sets $U$ in $\mathbb{Q}^* $ are the open sets of $\mathbb{Q}$ and the complement of compact sets of $\mathbb{Q}$, that is $U=\mathbb{Q}^* - K$ for some compact $K \subset \mathbb{Q}$). The important step in this proof is the following result:
Every compact set in $\mathbb{Q}$ has empty interior
whose proof can be read here. Since this space is compact (well, it is a compactification), then every closed set is compact. However, this space is not Hausdorff. Now, let $V$ be any open set in $\mathbb{Q}$ which is not dense, for example $V=(-\infty, 0) \cap \mathbb{Q}$. Then $\operatorname{cl}_{\mathbb{Q}^* }(V) = \operatorname{cl}_{\mathbb{Q}}(V) \cup \{p\}$. I claim this set is not the support of any function. In fact, let $f : \mathbb{Q}^* \to \mathbb{R}$ be a continuous function, and suppose $f(p)=\alpha$ and $f(r)=\beta$ for some $r \in \mathbb{Q}$ and $\alpha \neq \beta$. Then $\alpha$ and $\beta$ have disjoint neighborhoods $U$ and $V$, but then $f^{-1}(U)$ is a neighborhood of $p$ and it is the complement of a set with empty interior, and $f^{-1}(V)$ is an open set in $\mathbb{Q}$ and therefore there exists in interval such that $I \cap \mathbb{Q} \subset f^{-1}(V) \subset  \mathbb{Q}^* - f^{-1}(U)$, which is impossible. Therefore $f$ must be constant! And the only supports of continuous functions are $\emptyset$ and the whole space $\mathbb{Q}^* $. Hence we have found an example of a compact $T_1$ space $\mathbb{Q}^* $ and a compact set which is the closure of an open $F_\sigma$-set (since $\mathbb{Q}$ is denumerable), but is not the support of a continuous function, showing that the claim above only follows in normal spaces.
(Obs.: We have also proved this space in not normal. In fact, it is a known fact that a space is normal if and only if Tietze Extension Theorem is true. On the other hand, if $A = \{0,1\}$ and $f : A \to \mathbb{R}$ is defined by $f(x)=x$ than $f$ is clearly continuous, but it does not have a continuous extension on $\mathbb{Q}^* $ since it is not constant.)
A: Give {0,1} the topology { empty set, {0}, {0,1} }.
Let f(0) = 0, f(1) = 1.
The support of f is {1} which is not the closure of an open set.  
