I have a question about an application of the residue theorem to real definite integrals.

In "COMPLEX ANALYSIS" by Ahlfors, there is the following statement:

The integral

where P(z) and Q(z) are polynomials of degree m and n, respectively,

exists if and only if

and Q(z) has no zeros on real axis.

A brief proof of the sufficiency follows the statement.

But, there isn't the proof of the necessity.

And, I couldn't find it in any other book on complex analysis.

I'm grateful if someone could give me a proof of the necessity of the statement above.