> In short, the issue is, when given the following code:
> 
> 
>  struct A {...};
>  struct B { ...; struct A a; ...; };
>
> 
>  void f() {
>    B b;
>    g(&b.a);
>  }
>
> does the compiler have to assume that "g" may access the parts of "b" 
> outside of "a". 

I understand that you are talking about ISO C, but one relevant case (in C++) 
to look out for that is similar is this one, which certainly constitutes 
legitimate and widespread use of language features:

  class A {...};
  class B : public A { ... };

  void f() {
    B b;
    g (static_cast<A*> (&b));
  }

  void g(A *a) {
    B *b = dynamic_cast<B*>(a);
    // do what you please with the full object B
  }

dynamic_cast<> was invented for the particular reason to allow such 
constructs.

I admit ignorance how exactly the C++ FE describes base class information (as 
opposed to structure member information), but the aliasing code what have to 
know about the difference.

Best
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            [EMAIL PROTECTED]
                               www: http://www.ices.utexas.edu/~bangerth/

Reply via email to