Nonhyperbolic free-by-cyclic and one-relator groups