Let M 7 be a smooth manifold equipped with a G 2 -structure φ, and Y 3 be a closed compact φ-associative submanifold. In [17], R. McLean proved that the moduli space M Y,φ of the φ-associative deformations of Y has vanishing virtual dimension. In this paper, we perturb φ into a G 2 -structure ψ in order to ensure the smoothness of M Y,ψ near Y . If Y is allowed to have a boundary moving in a fixed coassociative submanifold X, it was proved in [7] that the moduli space M Y,X of the associative deformations of Y with boundary in X has finite virtual dimension. We show here that a generic perturbation of the boundary condition X into X ′ gives the smoothness of M Y,X ′ . In another direction, we use Bochner's technique to prove a vanishing theorem that forces M Y or M Y,X to be smooth near Y . For every case, some explicit families of examples will be given. MSC 2000: 53C38 (35J55, 53C21, 58J32).