We all know the rule of integration by parts:
$$\int a(x)b'(x)dx=a(x)b(x)-\int a'(x)b(x)dx$$
But most calculus textbooks lay it down without proper discussion, since what happens if the product $a(x)b(x)$ is a constant? Do many high school teachers miss this point?
The equality sign as it is written in your question is a "fake" one; it should mean "to be equal to up to a constant" in that context.
Let $f$ be a continuously differentiable map; let $g$ be a differentiable map; then $(fg)' = f'g + fg'$ everywhere suitable, and hence $fg + \text{some constant} = \int (fg)' = \int f'g + \int fg'$. Hence nothing is wrong with $f,g$ being constant or not.