Can an indefinite integral evaluate to zero?

Let $$I =\int\frac{\sin x+\cos x}{\cos^2 x+\sin^4 x}dx$$

Now we can write $\cos^2 x+\sin^4 x = \sin^4 x-\sin^2 x+1 = \cos^4 x-\cos^2 x+1$

So $$I = \int\frac{\sin x}{\cos^4 x-\cos^2 x+1}dx+\int\frac{\cos x}{\sin^4 x-\sin^2 x+1}dx$$

Now put $\cos x=t\;,$ Then $\sin xdx = -dt$ and put $\sin x=u\;,$ Then $\cos dx = du$

So $$I = -\underbrace{\int\frac{1}{t^4-t^2+1}dt}_{J}+\underbrace{\int\frac{1}{u^4-u^2+1}du}_{K}$$

Now Let $$J = \int\frac{1}{t^4-t^2+1}dt = \frac{1}{2}\int\frac{(t^2+1)-(t^2-1)}{t^4-t^2+1}dt$$

So $$J =\frac{1}{2}\int\frac{t^2+1}{t^4-t^2+1}dt+\frac{1}{2}\int\frac{t^2-1}{t^4-t^2+1}dt$$

So $$J = \frac{1}{2}\int\frac{1+\frac{1}{t^2}}{\left(t-\frac{1}{t}\right)^2+1}+\frac{1}{2}\int\frac{1-\frac{1}{t^2}}{\left(t+\frac{1}{t}\right)^2+3}dt$$

So we get $$J = \tan^{-1}\left(\frac{t^2-1}{t}\right)+\frac{1}{2\sqrt{3}}\ln \left|\frac{t^2-\sqrt{3}t+1}{t^2+\sqrt{3}t+1}\right|$$

Same calculation for $J$

So we get $$I = -\tan^{-1}\left(\frac{\cos^2 x-1}{\cos x}\right)-\frac{1}{2\sqrt{3}}\ln \left|\frac{\cos^2 x-\sqrt{3}\cos x+1}{\cos^2 x+\sqrt{3}\cos x+1}\right|+\tan^{-1}\left(\frac{\sin^2 x-1}{\sin x}\right)+\frac{1}{2\sqrt{3}}\ln \left|\frac{\sin^2 x-\sqrt{3}\sin x+1}{\sin^2 x+\sqrt{3}\sin x+1}\right|+\mathcal{C}$$


If you had, for example, $\displaystyle\int_0^{\pi/2}\!,$ then your $I_1$ would become $\displaystyle\int_0^1$ whereas $I_2$ would become $\displaystyle\int_1^0 = -\int_0^1$ and then $I_1-I_2$ would be $\displaystyle\int_0^1 - \left(-\int_0^1\right) = 2\int_0^1.$

But these are not definite integrals. One of them becomes $F(t) + C = F(\cos x)$ and the other $-F(u) = -F(\sin x) + C$, where $F$ is the same function in both cases. (And $C$ would in general not be the same in both cases.) So they don't cancel each other out even though $F$ is the same in both cases.