volatile [was: GCC warnings for unused global variables]
Michael Eager
eager@eagercon.com
Sun May 4 07:32:00 GMT 2003
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
More information about the Gcc
mailing list