This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Proposed resolution to aliasing issue.
- From: Wolfgang Bangerth <bangerth at ices dot utexas dot edu>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Wed, 11 May 2005 15:07:28 -0500
- Subject: Re: Proposed resolution to aliasing issue.
> 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: bangerth@ices.utexas.edu
www: http://www.ices.utexas.edu/~bangerth/