Graphene is known as a two-dimensional Dirac semimetal, in which electron states are described by the Dirac equation of relativistic quantum mechanics. Three-dimensional analogs of graphene are characterized by Dirac points or lines in momentum space, which are protected by symmetry. Here, we report a novel 3D carbon allotrope belonging to a class of topological nodal line semimetals, discovered using an evolutionary structure search method. The new carbon phase in the monoclinic C2/m space group, termed m-C8, consists of five-membered rings with sp3 bonding interconnected by sp2-bonded carbon networks. Enthalpy calculations reveal that m-C8 is more favorable than recently reported topological semimetallic carbon allotropes, and the dynamic stability of m-C8 is verified by phonon spectra and molecular dynamics simulations. Simulated X-ray diffraction patterns indicate that m-C8 could be one of the unidentified carbon phases observed in detonation shoot. The analysis of electronic properties indicates that m-C8 exhibits a nodal line protected by both inversion and time-reversal symmetries in the absence of spin-orbit coupling and the surface band connecting the projected nodal points. Our results may help design new carbon allotropes with exotic electronic properties.