If we have a charge density that depends only on $z$ (i.e. $y$ and $x$ are infinite) and of the form $$\rho(z)=Cz^2, \qquad z\in[-d/2,d/2]$$ then when calculating the electric field one finds: $$E=\frac{Cz^3}{3\epsilon_0}, \qquad z\in[0,d/2]$$ and $$E=\frac{Cd^3}{24\epsilon_0}, \qquad z\in[d/2,\infty[.$$
I know I can figure out the potential using a contour integral of the electric field from a reference to an arbitrary point on the field. However, why can I not set the potential to be zero at infinity, and even more importantly, why can I set the potential to zero at $z=0$?