How far can we push the Fundamental Theorem of Calculus for Riemann integral? Let $f:[a,b] \rightarrow \mathbb{R}$ be a continuous function such that it is differentiable everywhere unless in a null set $S$. Suppose that there is a function $g$, which is bounded and Riemann integrable in $[a,b]$, such that $g(x) = f'(x)$ for every $x\in [a,b] -S$. Then,
$$ f(b)-f(a) = \int^b_a g  $$
is true? If it is false, provide a counterexample and consider the case in which we switch "null set" by "countable set". In this case, it will be true? If not, provides a counterexample. I know that it would be true if we have finite set instead of null set. 
Remark: I am asking this question because I am studying a Brazilian book about Fourier Analysis ("Análise de fourier e equações diferenciais parcias" whose author is Djairo), in which he just uses Riemann integral and uses many times integration by parts. However, he just say "let $f$ be continuous in a closed and bounded interval such that $f'$ is integrable in the same interval" and then he uses integration by parts (the other function is $\cos$ or $\sin$ usually). And he doesn't define which he means by the "derivative" of a function, because if $f$ is differentiable everywhere, it would redundant to say that it is continuous. Would it be differentiable everywhere unless in a null set, countable set, finite set? Idk. This is why i am asking how far I can push the fundamental theorem of calculus, which is used to prove integration by parts.
Edits: 
Thanks for the comments, the case in which $S$ is a null set is already solved. It's false. The counterexample is the Cantor function. It remains the case in which $S$ is countable.
Here: "A Fundamental Theorem of Calculus" there's a similar problem, but I m not sure if it is equivalent. Anyway, I would really appreciate if my problem were solved not using Lebesgue theory, which i haven't studied yet. 
I had to fix the statement of the problem because it was wrong, as pointed out in the comments. Originally, i thought that it was enough that $f$ was differentiable in $[a,b]-S$ and one can extend $f'$ in any way, but then $\int_a^b f'$ will not exist necessarily, and we won't obviously have $ f(b)-f(a) = \int^b_a f'$.
 A: Yes, if $f'$ is Riemann integrable then $\int_a^bf'=f(b)-f(a)$. I've posted a proof of this before, but it's simple enough that  giving the proof again seems easier than trying to find that post:
Say $a=x_0<\dots<x_n=b$ is a partition of $[a,b]$. The Mean Value Theorem shows that there exists $\xi_j\in(x_{j-1},x_j)$ such that $$f(x_j)-f(x_{j-1})=f'(\xi_j)(x_j-x_{j-1}).$$So $$f(b)-f(a)=\sum_j(f(x_j)-f(x_{j-1}))=\sum_jf'(\xi_j)(x_j-x_{j-1}).$$But that last sum is precisely a Riemann sum for $\int_a^b f'$, so for any $\epsilon>0$ the last sum above is within $\epsilon$ of $\int_a^bf'$ if $\max_j(x_j-x_{j-1})$ is small enough.
So $$\left|f(b)-f(a)-\int_a^b f'\right|<\epsilon$$for every $\epsilon>0$.
Now what if $f$ is just differentiable on $[a,b]\setminus S$? No if we assume just that $S$ is a null set. I don't know the answer if $S$ is countable, but I suspect it's no. Yes if $S$ is finite (and $f$ is globally continuous):
Say $S=(a_j)$, where $a_1<\dots<a_n$. The case proved above shows that
$$f(a_{j+1})-f(a_j)=\lim_{\epsilon\to0}(f(a_{j+1}-\epsilon)-f(a_j+\epsilon))=\lim_{\epsilon\to0}\int_{a_j+\epsilon}^{a_{j+1}-\epsilon}f'=\int_{a_j}^{a_{j+1}}f';$$now take the sum over $j$.
A: I don't know the answer assuming that $S$ is countable. But yes, FTC holds if $S$ is a countable closed set:


Lemma 0. Suppose $f:(-1,1)\to\Bbb R$ is continuous and $f'(t)=0$ for all $t\ne0$. Then ($f$ is differentiable at the origin and) $f'(0)=0$.


Proof: $f$ is constant on $(-1,0]$ and constant on $[0,1)$; hence $f$ is constant.


Lemma 1. Suppose $S\subset[0,1]$ is a countable closed set, $f:[0,1]\to\Bbb R$ is continuous and $f'(t)=0$ for all $t\in[0,1]\setminus S$. Then $f$ is constant.


Proof: For $E\subset\Bbb R$ let $I(E)$ be the set of isolated points of $E$. Define $S_\alpha$ for ordinals $\alpha$ by $S_0=S$, $$S_{\alpha+1}=S_\alpha\setminus I(S_\alpha)$$and $$S_\alpha=\bigcap_{\beta<\alpha}S_\beta\quad(\alpha\text{ is a limit ordinal)}.$$
Show by induction on $\alpha$ that $S_\alpha$ is a countable closed set and $f'=0$ on $[0,1]\setminus S_\alpha$.
There must exist $\alpha$ with $S_{\alpha+1}=S_\alpha$. A nonempty closed set with no isolated points is uncountable (look up "perfect set" on Wikipedia); hence  $S_\alpha=\emptyset$.


Prop. Suppose $S\subset[0,1]$ is countable closed set,  $f:[0,1]\to\Bbb R$ is continuous and $f$ is differentiable on $[0,1]\setminus S$. If there exists a Riemann integrable function $g$ such that $g=f'$ on $[0,1]\setminus S$ then $f(1)-f(0)=\int_0^1g(t)\,dt.$


Proof. Define $$F(x)=f(x)-\int_0^xg(t)\,dt.$$(Note that $F$ is continuous since $g$ is bounded.)
Suppose $[a,b]\subset[0,1]\setminus S$. Since FTC  holds for differentiable functions with a Riemann integrable derivative, $$F(b)-F(a)=f(b)-f(a)-\int_a^bf'(t)\,dt=0.$$
Since $S$ is closed, the previous paragraph shows that $F'(t)=0$ for all $t\in[0,1]\setminus S$. So Lemma 1 implies $F$ is constant, hence $$f(1)-\int_0^1g(t)\,dt=F(1)=F(0)=f(0).$$
Edit: In fact Lemma 1 holds  if $S$ is any countable  set; see here or here. But I don't quite see how to get the Prop from Lemma 1 if $S$ is not closed.
