Suppose $f$ is a bounded real function on $[a,b]$ and $f^2$ is Riemann integrable on $[a,b]$.
$f^2$ is Riemann integrable does not imply $f$ is Riemann integrable. As an example, $f = -1$ when $x$ is irrational; $f = 1$ when $x$ is rational.
However, if $f^3$ is Riemann integrable, then $f$ is Riemann integrable because: if $f^3$ is Riemann integrable on $[a,b]$, then $[f(a)]^3\le f^3 \le [f(b)]^3$. Since $g(u) = u^\frac13$ is obiviously on $[[f(a)]^3, [f(b)]^3], g[f^3(x)] = f(x)$ is Riemann integrable on $[a,b]$.
What if I use $\psi(u) = u^\frac12$ to replace the $g(u)$ above, then we can prove that $f^2$ is Riemann integrable implies $f$ is Riemann integrable, doesn't it? But this is wrong. Then, what's wrong with the later proof?