A simple problem for a $1$D-wave equation $$u_{tt} = u_{xx}$$ with conditions \begin{align} u(0,t) &= 0; \\ u(\pi,t) &= 0; \\ u(x,0) &= f(x) = 1 - \cos(2x); \\ u_t &= 0; \end{align} can be solved using D'Alembert identity, the solution of this equation is $$ \frac{f(x+at)+f(x-at)}{2} = \frac{1 - \cos(2(x+t)) + 1 - \cos(2(x-t))}{2}. $$ Now, if I put $t = \frac{\pi}{2}$ and $x = 0$, I get $u(0,\frac{\pi}{2}) = 4$. This violates the boundary condition $u(0,t) = 0$.
I think this is due to the fact that that $f(x)$ is only defined on the interval between 0 and $\pi$ (and not defined for $x = -\pi$). This will mean that D'Alembert solution is only defined only on a certain interval of $t$ (so if we want $t$ to go from $-\infty$ to $\infty$, we cannot use this solution?).