Casting magnesium alloys are heterogeneous materials containing numerous voids. Assuming the voids are spherical, in the present investigation, the evolution equations of the growth and nucleation of the voids have been presented. Combining the evolution equation of the void growth with that of the void nucleation, the evolution rule of the voids was obtained. Based on the void evolution rule a nonclassical elastoplastic constitutive model involving void evolution was developed. The corresponding numerical algorithm and finite element procedure were developed and applied to the analyses of the elastoplastic response and the porosity of casting magnesium alloy. The calculated results show the satisfactory agreement with experiments.