This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC warnings for unused global variables
On Fri, May 02, 2003 at 06:00:30PM +0200, Gabriel Dos Reis wrote:
> | Because, since the object is volatile, it may affect the program in
> | ways unknown to the compiler.
>
> This is my favorite peeve against the definition of "volatile".
> Does an alpha ray fired from Centauri count as a "way unknown to the
> compiler"?
This is a much better example than you thought it was. The answer is
"yes". Alpha particles are a major source of soft errors; they can
spontaneously change the value that is stored in RAM. Duplicated
reads can't be eliminated because they might miss the change caused
by the alpha particle. A memory test might be written in C with
a big volatile array, and one of the things it would be looking for
is effects caused by alpha particles.
(Of course, an alpha particle can't make it through the atmosphere,
so you'll need to pick some other particle or photon type).