From: Mark Mitchell <mark@codesourcery.com>
To: jlm@maths.soton.ac.uk
Cc: gcc@gcc.gnu.org
Subject: Re: aliasing
Date: Sat, 21 Aug 1999 09:46:00 -0000 [thread overview]
Message-ID: <19990821095213W.mitchell@codesourcery.com> (raw)
In-Reply-To: <199908211622.RAA18934@malone.maths.soton.ac.uk>
The relevant paragraph is in [basic.lval] of the C++ standard. The
paragraph in the C standard is nearly identical. Here it is. Perhaps
someone would like to HTML-ify this, and make a FAQ entry out of it?
If a program attempts to access the stored value of an object
through an lvalue of other than one of the following types the
behavior is undefined:
--the dynamic type of the object,
You can access an object using the type it really has. (I.e., you can
use an `int *' to refer to an `int'.)
--a cv-qualified version of the dynamic type of the object,
You can also use a `const int *' to read an `int'.
--a type that is the signed or unsigned type corresponding to the
dynamic type of the object,
Or an `unsigned int *'.
--a type that is the signed or unsigned type corresponding to a cv-
qualified version of the dynamic type of the object,
Or a `const unsigned int *'.
--an aggregate or union type that includes one of the aforementioned
types among its members (including, recursively, a member of a
sub-aggregate or contained union),
You can read or write an entire structure, thereby accessing all of
its fields.
--a type that is a (possibly cv-qualified) base class type of the
dynamic type of the object,
This one is C++-specific. You can read or write an entire base class
of the actual type of the object.
--a char or unsigned char type.
You can use a `char *', `unsigned char *', `volatile char *',
`unsigned const volatile char *', etc. to read or write from anywhere.
All pointer types here can be replaced with reference types as well.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
WARNING: multiple messages have this Message-ID
From: Mark Mitchell <mark@codesourcery.com>
To: jlm@maths.soton.ac.uk
Cc: gcc@gcc.gnu.org
Subject: Re: aliasing
Date: Tue, 31 Aug 1999 23:20:00 -0000 [thread overview]
Message-ID: <19990821095213W.mitchell@codesourcery.com> (raw)
Message-ID: <19990831232000.gE4xGLvGLVlojaPwh_JKKNh3SraiIjkYadZSPc2FGsY@z> (raw)
In-Reply-To: <199908211622.RAA18934@malone.maths.soton.ac.uk>
The relevant paragraph is in [basic.lval] of the C++ standard. The
paragraph in the C standard is nearly identical. Here it is. Perhaps
someone would like to HTML-ify this, and make a FAQ entry out of it?
If a program attempts to access the stored value of an object
through an lvalue of other than one of the following types the
behavior is undefined:
--the dynamic type of the object,
You can access an object using the type it really has. (I.e., you can
use an `int *' to refer to an `int'.)
--a cv-qualified version of the dynamic type of the object,
You can also use a `const int *' to read an `int'.
--a type that is the signed or unsigned type corresponding to the
dynamic type of the object,
Or an `unsigned int *'.
--a type that is the signed or unsigned type corresponding to a cv-
qualified version of the dynamic type of the object,
Or a `const unsigned int *'.
--an aggregate or union type that includes one of the aforementioned
types among its members (including, recursively, a member of a
sub-aggregate or contained union),
You can read or write an entire structure, thereby accessing all of
its fields.
--a type that is a (possibly cv-qualified) base class type of the
dynamic type of the object,
This one is C++-specific. You can read or write an entire base class
of the actual type of the object.
--a char or unsigned char type.
You can use a `char *', `unsigned char *', `volatile char *',
`unsigned const volatile char *', etc. to read or write from anywhere.
All pointer types here can be replaced with reference types as well.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
next prev parent reply other threads:[~1999-08-21 9:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-21 9:23 aliasing Jason Moxham
1999-08-21 9:46 ` Mark Mitchell [this message]
1999-08-31 23:20 ` aliasing Mark Mitchell
1999-08-31 23:20 ` aliasing Jason Moxham
2024-03-18 7:03 aliasing Martin Uecker
2024-03-18 8:26 ` aliasing Richard Biener
2024-03-18 10:55 ` aliasing Martin Uecker
2024-03-18 11:56 ` aliasing Martin Uecker
2024-03-18 13:21 ` aliasing Richard Biener
2024-03-18 15:13 ` aliasing Martin Uecker
2024-03-18 9:00 ` aliasing David Brown
2024-03-18 10:09 ` aliasing Jonathan Wakely
2024-03-18 11:41 ` aliasing Martin Uecker
2024-03-18 13:29 ` aliasing David Brown
2024-03-18 13:54 ` aliasing Andreas Schwab
2024-03-18 16:46 ` aliasing David Brown
2024-03-18 16:55 ` aliasing David Brown
2024-03-18 15:00 ` aliasing Martin Uecker
2024-03-18 17:11 ` aliasing David Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19990821095213W.mitchell@codesourcery.com \
--to=mark@codesourcery.com \
--cc=gcc@gcc.gnu.org \
--cc=jlm@maths.soton.ac.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).