Let $X,Y,Z$ be integral schemes and $f:X\to Y$, $g:Y\to Z$ be morphisms such that $g$ is flat and $f$ is not flat. Does this imply that the composition $g\circ f:X\to Z$ is necessarily non-flat?
[EDIT: ykm's example works but I'm also interested to know the answer in the case where $X,Y,Z$ have the same dimension].