The correct statement is: if $F'(x)=f(x)$ for all $x\in[a,b]$, and $f$ is Riemann integrable on $[a,b]$, then
$$
\int_{a}^{b}f(x) \, dx=F(b)-F(a) \, .
$$
To understand why the condition "$f$ is Riemann integrable on $[a,b]$" is important, consider the function
$$
F(x)=\begin{cases}
x^2\sin\left(\dfrac{1}{x^2}\right) &\text{ if $x\neq0$} \\
0 &\text{ if $x=0$} \, .
\end{cases}
$$
Its derivative is
$$
f(x)=\begin{cases}
\displaystyle{2x\sin\left(\frac{1}{x^2}\right)-\frac{2\cos\left(\frac{1}{x^2}\right)}{x}} &\text{if $x\neq0$} \\
0 &\text{if $x=0$} \, .
\end{cases}
$$
We might be tempted to think that
$$
\int_{-1}^{1}f(x) \, dx = F(1)-F(-1) \, ,
$$
but $f$ is unbounded on $[-1,1]$, and so is not Riemann integrable on $[-1,1]$. So the fact that $f$ is the derivative of another function $F$ on $[a,b]$ is by no means a guarantee that $\int_{a}^{b}f(x) \, dx$ exists. There are even 'worse' examples: consider Volterra's function.
The good news is that if $f$ is continuous on $[a,b]$, then $f$ is Riemann integrable on $[a,b]$. We tend to integrate elementary functions, and every elementary function is continuous on its domain. So in practice these problems rarely crop up.
In fact, the condition that $f$ is Riemann integrable on $[a,b]$ is equivalent to $f$ being bounded on $[a,b]$ and continuous almost everywhere. The phrase almost everywhere has a precise meaning in measure theory. Here, it is equivalent to asking that the set of discontinuities $D$ of $f$ on $[a,b]$ is a null set: for every $\varepsilon>0$, there is a sequence of open intervals whose union contains $D$, and the sum of the lengths of those intervals is less than $\varepsilon$.