This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: volatile semantics
Dale Johannesen <dalej@apple.com> writes:
| > the type of an object
| > changes depending on how it is accessed.
|
| this also makes nonsense of gcc's implementation of type-based aliasing
| rules.
|
| *((int *)&x) = 3
No. That one is specifically covered by the C and C++ standards
(although they use different terminologies). C uses the notion of
*effective type* to formulate the rule.
[#6] The effective type of an object for an access to its
stored value is the declared type of the object, if any.72)
If a value is stored into an object having no declared type
through an lvalue having a type that is not a character
type, then the type of the lvalue becomes the effective type
of the object for that access and for subsequent accesses
that do not modify the stored value. If a value is copied
into an object having no declared type using memcpy or
memmove, or is copied as an array of character type, then
the effective type of the modified object for that access
and for subsequent accesses that do not modify the value is
the effective type of the object from which the value is
copied, if it has one. For all other accesses to an object
having no declared type, the effective type of the object is
simply the type of the lvalue used for the access.
-- Gaby