This is the mail archive of the gcc@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]

Question about aliases


Hello.

I've been watching the sources of aliasing in gcc and found one
comment, that seemed to me a bit strange. In file `gcc/alias.c' in
function `get_alias_set':

>   /* From the former common C and C++ langhook implementation:
>
>      Unfortunately, there is no canonical form of a pointer type.
>      In particular, if we have `typedef int I', then `int *', and
>      `I *' are different types.  So, we have to pick a canonical
>      representative.  We do this below.
>
>      Technically, this approach is actually more conservative that
>      it needs to be.  In particular, `const int *' and `int *'
>      should be in different alias sets, according to the C and C++
>      standard, since their types are not the same, and so,
>      technically, an `int **' and `const int **' cannot point at
>      the same thing.

Please, can you explain the following:

According to the standard

> A typedef declaration does not introduce a new type, only a synonym for the type so specified.

So, as I understand in this case `I *' and `int *' should be equal types?


Also, according to the issue 6.5 (7), we cat access to an object value
with expression that has

> a qualified version of a type compatible with the effective type of the object

So, `const int *' can legally point to the `int *' but not in reverse
order, and that's why `const int *' and `int *' should be in different
alias sets?


Alex.


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