Question 2.1 of Bartle's Elements of Integration The problem 2.1 of Bartle's Elements of Integration says:

Give an exemple of a function $f$ on $X$ to $\mathbb{R}$ which is not
  $\boldsymbol{X}$-mensurable, but is such that the function $|f|$ and
  $f^2$ are $\boldsymbol{X}$-mensurable.

But, if one define $f^{+}:= \max\{f(x), 0\}$ e $f^{-}\max\{-f(x),0\}$, then $f = f^{+} - f^{-}$ and $|f| = f^{+}+f^{-}$. Also, $f$ is $\boldsymbol{X}$-mensurable iff $f^{+}$ and $f^{-}$ are mensurable. Therefore, $|f|$ is mensurable iff $f$ is mensurable. Is the problem wrong?
Edit:
Here $X$ is a set and $\boldsymbol{X}$ a $\sigma$-algebra over $X$.

Take any non-empty measurable set $U$ in $X$, and any non-empty non-measurable set $V$ in $U$. Let $f$ be the function that sends $U$ to $1$, except for the points in $V$, which are sent to $-1$. In other words, $f(x) = 1_{U\backslash V} - 1_V$.
Now $|f| =f^2 = 1_U$.
I see now that Bunder has written a similar idea (that I don't think is fleshed out yet as I see it so far).
EDIT (to match the edited question)
You ask:

But, if one define $f^+:=\max\{f(x),0\}$ and $f^−= \max\{−f(x),0\}$, then $f=f^+−f^−$ and $|f|=f^++f^−$. Also, $f$ is $X$-mensurable iff $f^+$ and $f^−$ are mensurable. Therefore, $|f|$ is mensurable iff $f$ is mensurable. Is the problem wrong?

What makes you think that $f$ is measurable iff $f^+$ and $f^-$ are measurable? In my example above, $f^+ = 1_{U\backslash V}$ and $f^- = 1_V$, neither of which are measurable. This is clear for $1_V$. To see that $f^+$ here is not measurable, note that if it were measurable, then $1 - f^+ = 1_V$ would be measurable. But their sum is $1_U$, which is trivially measurable.
In other words, it is not true that $f$ measurable iff $f^+, f^-$ measurable.
