From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Mitchell To: jlm@maths.soton.ac.uk Cc: gcc@gcc.gnu.org Subject: Re: aliasing Date: Tue, 31 Aug 1999 23:20:00 -0000 Message-ID: <19990821095213W.mitchell@codesourcery.com> References: <199908211622.RAA18934@malone.maths.soton.ac.uk> X-SW-Source: 1999-08n/msg00646.html Message-ID: <19990831232000.gE4xGLvGLVlojaPwh_JKKNh3SraiIjkYadZSPc2FGsY@z> 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