Does this improper integral converge or is it a trick question?

I have this improper integral:

$$\int_{-\infty}^{\infty}xe^{-x^2}\ dx$$

During my lecture we were told to find whether it converges or diverges, and I found it converged because after calculating the integral:

$$\frac{-e^{-x^2}}{2}$$

I can see adding infinity for x will make the fraction $=0$. We were told it was a trick question, something something about negatives, and we moved on. But I'm still wondering why the answer isn't that it converges because it still looks correct to me?

The function $f(x) = x e^{-x^2}$ is infinitely often differentiable and has an antiderivative $F(x) = -\frac12 e^{-x^2}$ everywhere on $\mathbb R$. The improper integral is defined by $$\int_{-\infty}^\infty f(x)\,dx = \lim_{y\to-\infty}\int_y^c f(x)\,dx + \lim_{y\to\infty} \int_c^y f(x)\,dx$$ With this knowledge we get $$\int_{-\infty}^\infty f(x)\,dx = \lim_{y\to-\infty}\bigl(F(c) - F(y)\bigr) + \lim_{y\to\infty} \bigl(F(y) - F(c)\bigr) = -\lim_{y\to\infty}e^{-y^2} = 0$$ since $F$ is symmetric and the limit is obvious.
• @user247327 One can get in trouble applying this line of reasoning to improper integrals: The function $x \mapsto \frac{x}{1 + x^2}$ is odd but $\int_{-\infty}^{\infty} \frac{x \,dx}{1 + x^2}$ is divergent. May 18, 2017 at 12:51
• @Travis Thank you for providing this example! We can clearly see that $\int_{-\infty}^\infty f(x)\,dx = \lim_{y\to-\infty}\int_y^c f(x)\,dx + \lim_{y\to\infty} \int_c^y f(x)\,dx \neq \lim_{y\to\infty}\int_{-y}^y f(x)\,dx$ in general! May 18, 2017 at 13:11