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:

[...]

| Of course, the standard does contain the general clause
| "The properties ascribed to objects throughout this International
| Standard apply for a given object only during its lifetime." (3.8/3).
| So you could argue that 7.1.5.1/7 doesn't apply before the constructor
| is complete.

Rightly.

|  However, in the lack of any explicit definition of what
| it means to refer to a volatile-qualified object through a non-volatile
| qualified type would tend to suggest that the behaviour was implicitly
| undefined anyway, even if not explicitly undefined.

The standatrds does provide this general wording: 

  Some objects are polymorphic (10.3); the implementation generates
  information associated with each such object that makes it possible
  to determine that object's type during program execution. For other
  objects, the interpretation of the values found therein is 
  determined by the type of the expressions (clause 5) used to access
  them. 

which pretty much answers the question.

| But more to the point, volatile is generally used with PODs/aggregates,
| in which case there is no constructor to worry about, just an initializer.

That statement is wrong.  For POD/aggregates there still are issues
about lifetime.  POD does not mean lifetime-less. 


| The C++ committee was not too worried about nailing down the semantics
| of volatile for class objects, since they did not expect it to be used
| (or useful) for class objects.

This statement is clearly wrong since the committee does consider
member functions that are volatile-qualified which, for one thing, is
an indication that volatile was expected to be used with classes.

-- Gaby


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