On the non-occurrence of the Lavrentiev phenomenon