Re: strict aliasing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ingo Rohloff wrote:
...skillful elision by patrick who is rarely caught top posting;)...
Is the above statement OK or not ?
Yep
Or is it, because "ptr2" is an "unsigned char *", that ptr2 is assumed to
be able to alias anything ? (Because it is a char pointer).
Yep
Does these "char pointer can alias anything" really only refer to "char *"
or also to "unsigned char *".
Any char type--see below.

C++ spec says (along with a footnote that says: 49) The intent of this list is to specify those circumstances in which an object may or may not be aliased.)

15 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,
— a cv-qualified version of the dynamic type of the object,
— a type similar (as defined in 4.4) to the dynamic type of the object,
— a type that is the signed or unsigned type corresponding to the dynamic type of the object, — a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type of the object, — an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), — a type that is a (possibly cv-qualified) base class type of the dynamic type of the object,
— a char or unsigned char type.


so accessing as a char * is ok. They did this for backward compatibility with bazillions of programs which do this.

Patrick


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux