IMA vs tree-ssa

Dale Johannesen dalej@apple.com
Tue Mar 9 00:07:00 GMT 2004


On Mar 8, 2004, at 3:32 PM, Joe Buck wrote:
> On Mon, Mar 08, 2004 at 11:57:00PM +0100, Gabriel Dos Reis wrote:
>>        [#2] All declarations that  refer  to  the  same  object  or
>>        function shall have compatible type; otherwise, the behavior
>>        is undefined.
> This would seem to suggest that in the situations where non-transitive
> behavior would otherwise result (for example, an incomplete struct 
> type is
> compatible with two distinct and incompatible definitions of that 
> struct
> type), and this matters (for the purpose of aliasing analysis, for
> example), we have undefined behavior, so the compiler should be able to
> act as though this situation does not arise and assume transitivity.

Suppose we have 3 types T1, T2, Tcom such that T1 and T2
are not compatible, but Tcom is compatible with either T1 or T2.
Let's call the relationship between T1 and T2 "pseudo-compatible".
Then:

Tcom x;
T1 * p = (T1 *)&x;
T2 * q = (T2 *)&x;

foo()
{
    T1 x = *p;
    *q = ...
}

This is not undefined behavior, and the standard says that p and q 
don't alias
in foo.  But they do.  However, we are probably OK assuming that
pseudo-compatible types alias, even though the standard says they don't.

I can't construct an example of pseudo-compatible types where T1 and T2 
are visible in the
same scope, and believe this to be impossible.  So without IMI, there 
is no problem.
But this sort of thing can happen with crossfile inlining.

The more I think about this, the more I think Mark is right, this can 
of worms can't
be intentional.



More information about the Gcc mailing list