Commercially manufactured CDs have an extremely long shelf life, assuming they are properly handled and not exposed to UV light or extreme conditions. They will probably outlive you. Short shelf life is mainly an issue with cheap CD-R and DVD-R recordable media. The dyes tend to decay over time.
Recordable ones use dyes which fade if exposed to sunlight and temperature.
The pits that represent data in factory manufactured discs are laser etched, so if the polycarbonate layer doesn't decay in 50 years it should be OK. Betting they would as long as kept from moisture. Even if the reflective layer is compromised I think it would somehow be possible to reapply it to the polycarbonate layer which has the pits.
CD-ROMs and DVD-ROMs are similar in that they are replicated discs-that is, the data are physically pressed into the disc when it is manufactured. ROMs are generally mass-produced and contain music, video, computer applications, or interactive games.
ROM disc longevity is determined by the extent to which its aluminum layer is exposed to oxygen. Oxygen, including pollutants, can migrate through the polycarbonate layer or the hard lacquer layer (CD label side and edge), carried in by moisture. Oxygen or moisture can more easily penetrate through scratches, cracks, or delaminated areas in the label. Oxygen can also be trapped inside the disc during manufacturing, although manufacturing improvements have reduced the likelihood of this.
If left in a very humid environment, moisture-and oxygen-will eventually reach the aluminum, causing it to lose its reflectivity. The normally shiny aluminum, which resembles silver, becomes oxide-dull and much less reflective, like the color of a typical aluminum ladder. The combination of high humidity and increased temperatures will accelerate the oxidation rate.
The life expectancy of a ROM disc therefore depends on the environmental conditions to which it is exposed over time. Generally, it is best to keep ROM discs in a dry, cool environment. If the disc is removed from a humid, hot environment to an ideal condition before damage has been done, it will “dry out” and should be as playable as if it had been kept in ideal conditions all along. Other contaminates, however, such as inks, solvents, and pollutants, have the potential to irreversibly penetrate and to deform, discolor, or corrode the disc, causing permanent reading problems for the laser.