"Bernhard R. Link" <[EMAIL PROTECTED]> writes:

> * Ian Lance Taylor <[EMAIL PROTECTED]> [061108 16:15]:
> > This assumes, of course, that we can build an equivalence set for
> > types.  I think that we need to make that work in the middle-end, and
> > force the front-ends to conform.  As someone else mentioned, there are
> > horrific cases in C like a[] being compatible with both a[5] and a[10]
> > but a[5] and a[10] not being compatible with each other, and similarly
> > f() is compatible with f(int) and f(float) but the latter two are not
> > compatible with each other.
> 
> Isn't void* and anyothertype* the same case?

No.  What we are asking about here is which types are compatible in
the sense that they may be applied to the same object.  That is, these
two declarations are permitted:
    int a[];
    int a[10];
These two declarations are not permitted:
    void* p;
    int* p;
This is because int[] and int[10] are compatible types, but that void*
and int* are not compatible types.

The relationship between int* and void* is that code is permitted to
rely on an implicit conversion between the two types (in C; in C++
there is only an implicit conversion to void*, not away from it).

> And how are classes and parent classes made compatible in C++? Is the
> front end always making a implicit type conversion or are they 'equivalent'
> in one direction?

Again this is a case of type conversion, not type compatibility or
equivalence.

Ian

Reply via email to