If $f$ is infinitely differentiable then $f$ coincides with a polynomial
The proof is by contradiction. Assume $f$ is not a polynomial.
Consider the following closed sets: $$ S_n = \{x: f^{(n)}(x) = 0\} $$ and $$ X = \{x: \forall (a,b)\ni x: f\restriction_{(a,b)}\text{ is not a polynomial} \}. $$
It is clear that $X$ is a non-empty closed set without isolated points. Applying Baire category theorem to the covering $\{X\cap S_n\}$ of $X$ we get that there exists an interval $(a,b)$ such that $(a,b)\cap X$ is non-empty and $$ (a,b)\cap X\subset S_n $$ for some $n$. Since every $x\in (a,b)\cap X$ is an accumulation point we also have that $x\in S_m$ for all $m\ge n$ and $x\in (a,b)\cap X$.
Now consider any maximal interval $(c,e)\subset ((a,b)-X)$. Recall that $f$ is a polynomial of some degree $d$ on $(c,e)$. Therefore $f^{(d)}=\mathrm{const}\neq 0$ on $[c,e]$. Hence $d< n$. (Since either $c$ or $e$ is in $X$.)
So we get that $f^{(n)}=0$ on $(a,b)$ which is in contradiction with $(a,b)\cap X$ being non-empty.
Note that The Fabius function is nowhere analytic but admits a dense set of points where all but finitely many derivatives vanish.
The theorem:
Theorem: Let $f(x)$ be $C^\infty$ on $(c,d)$ such that for every point $x$ in the interval there exists an integer $N_x$ for which $f^{(N_x)}(x)=0$; then $f(x)$ is a polynomial.
is due to two Catalan mathematicians:
F. Sunyer i Balaguer, E. Corominas, Sur des conditions pour qu'une fonction infiniment dérivable soit un polynôme. Comptes Rendues Acad. Sci. Paris, 238 (1954), 558-559.
F. Sunyer i Balaguer, E. Corominas, Condiciones para que una función infinitamente derivable sea un polinomio. Rev. Mat. Hispano Americana, (4), 14 (1954).
The proof can also be found in the book (p. 53):
W. F. Donoghue, Distributions and Fourier Transforms, Academic Press, New York, 1969.
I will never forget it because in an "Exercise" of the "Opposition" to became "Full Professor" I was posed the following problem:
What are the real functions indefinitely differentiable on an interval such that a derivative vanish at each point?