This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: volatile structures: Is that a bug?
- From: Andrew Haley <aph at redhat dot com>
- To: etienne_lorrain at yahoo dot fr
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 19 Sep 2008 12:10:15 +0100
- Subject: Re: volatile structures: Is that a bug?
- References: <423.59171.qm@web28606.mail.ukl.yahoo.com>
Etienne Lorrain wrote:
>>> On C structures, for attributes like "const", it is enough to
>>> consider that each field inherit the attribute of the structure.
>>> But for the volatile attribute, is it valid to treat each field as
>>> volatile like GCC does it now?
>> "An object that has volatile-qualified type may be
>> modified in ways unknown to the implementation or
>> have other unknown side effects. Therefore any
>> expression referring to such an object shall be
>> evaluated strictly according to the rules of the abstract
>> machine, as described in 5.1.2.3."
>>
>> So, any reference to the object must treat the object as
>> volatile, and that includes any reference to any part of
>> the object.
>
> If I correctly understand you, GCC is wrong reading a byte when the
> byte is part of a volatile structure - GCC needs to read the complete
> structure first, and then extract the byte.
I didn't say that. Neither did the standard, by my reckoning.
Please read the standard, in particular the part that follows.
Andrew.