Theoretically the Kohn-Sham band gap differs from the exact quasiparticle energy gap by the derivative discontinuity of the exchange-correlation functional. In practice for semiconductors and insulators the band gap calculated within any local or semilocal density approximations underestimates severely the experimental energy gap. On the other hand, calculations with an "exact" exchange potential derived from many-body perturbation theory via the optimized effective potential suggest that improving the exchange-correlation potential approximation can yield a reasonable agreement between the Kohn-Sham band gap and the experimental gap. The results in this work show that this is not the case. In fact, we add to the exact exchange the correlation that corresponds to the dynamical (random phase approximation) screening in the GW approximation. This accurate exchange-correlation potential provides band structures similar to the local density approximation with the corresponding derivative discontinuity that contributes 30%-50% to the energy gap. Our self-consistent results confirm substantially the results for Si and other semiconductors obtained perturbatively [R. W. Godby , Phys. Rev. B 36, 6497 (1987)] and extend the conclusion to LiF and Ar, a wide-gap insulator and a noble-gas solid. (c) 2006 American Institute of Physics.