This is the mail archive of the
mailing list for the GCC project.
Question about aliases
- From: Alex Markin <alexanius at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 6 Nov 2012 12:23:28 +0300
- Subject: Question about aliases
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
> /* 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