On 6 November 2012 09:23, Alex Markin wrote: > 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,
A `const int*' can point to the same object as an `int*' points to, it can't point to the `int*' itself (as you wrote). Accessing a non-const `int' through a const int*' would be a case where the effective type of the object [int] is accessing through a qualified version of the type [const int], If the effective type is `const int' then an `int*' cannot point to it, because `int' is not `const int' and is not a qualified version of `const int'. But that's to do with what a `const int*' and `int*' can point to. That relates to the alias sets of `int' and `const int' which is not the same as `int*' and `const int*' > and that's why `const int *' and `int *' should be in different > alias sets? No, they are in different alias sets because a `const int**' and an `int**' cannot point to the same object. See http://c-faq.com/ansi/constmismatch.html