This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: volatile [was: GCC warnings for unused global variables]


Fergus Henderson <fjh@cs.mu.oz.au> writes:

| On 04-May-2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
| > Fergus Henderson <fjh@cs.mu.oz.au> writes:
| > | I do not agree that the text which you quoted permitted such optimization.
| > 
| > Still, it says so in black on white.
| 
| The C standard text which you quoted doesn't say that the optimization
| is permitted unconditionally. 
               ^^^^^^^^^^^^^^^

Which is not my claim.

| It only says that the optimization is
| permitted only "if [the implementation] can deduce that [the expression's]
| value is not used and that no needed side effects are produced". 

In what is that different from 

 # Why? the last part of the paragraph quoted above does specifically
 # permit that optimization where applicable.
 
quoted from http://gcc.gnu.org/ml/gcc/2003-05/msg00145.html ?

| In the
| case of volatile variables, this condition is always false,

No, because the standard does specifically add

  INCLUDING ANY CAUSED BY CALLING A FUNCTION OR ACCESSING A VOLATILE
  OBJECT 

| because the
| definition of volatile means that the implementation can never know if
| a side effect is "needed".

The definition of "volatile" does not say that the implementation can
never know if a side effect is needed.  what you've discovered is just
another facet of the ill-defined notion of "volatile".

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]