This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: alias question


>>> No: character types are special.  See Section 6.5 re arrays of
>>> character type and effective types.
>>
>> 6.5/6, first line: The effective typeof an object for an access to its
>> stored value is the declared type of the object, if any.
>>
>> No exception for character types here; there is in some other
>> aspects (like for accesses to allocated storage), but not for this.
>
> "If a value is copied into an object having no declared type using

_no declared type_

> 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...
>
> 7  An object shall have its stored value accessed only by an
> lvalue expression that has one of the following types: 73)
>
> ? a type compatible with the effective type of the object,
>
> ? a qualified version of a type compatible with the effective type of
> the object,
>
> ? a type that is the signed or unsigned type corresponding to the
> effective type of the object, ? a type that is the signed or unsigned
> type corresponding to a qualified version of the effective 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), or
>
> ? a character type.
>
> 73) The intent of this list is to specify those circumstances in which
> an object may or may not be aliased."
>
> In other words, a character type aliases all other types.

But not every type aliases character type!

> Without
> this, it's not possible to write malloc() in C.

You cannot have the "memory pool" be a declared array, yes.  You can get it
from mmap() or brk() or whatever just fine, the pointers those return are not
pointing to declared objects, so all those special rules apply, and you get
the effective type to be the type of what you store in the malloc()ed area.


Segher


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]