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 wrote:
> 
> On 03-May-2003, Michael Eager <eager@eagercon.com> wrote:
> > An unreferenced volatile variable has no reads or writes which need to be
> > represented.
> 
> I don't agree.  In C++, if the variable is static, it is first
> zero-initialized, which is a write that needs to be represented,
> and then if there is an initializer for it, it is initialized with
> that value, which is another write that needs to be represented.

I don't believe there is any requirement that static variables are
first set to zero and then set their initial value.  They can be
created with the initialized value, if that can be calculated at
compile time (e.g., if there is no constructor).  You describe a 
possible implementation, not required behavior.

The semantics of volatile are not complete.  (Actually, little of
the semantics is specified.)  Whether the memory which is occupied 
by a static volatile "sees" the initialization is not specified.   

-- 
Michael Eager    Eager Consulting     eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


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