IMA vs tree-ssa
Mark Mitchell
mark@codesourcery.com
Tue Mar 9 00:34:00 GMT 2004
Dale Johannesen wrote:
> 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.
Yes, this is precisely why I think that this is a defect in the C
standard, not an intentional decision. Surely if you only cast between
compatible types then things that really do alias in practice should
alias according to the standard.
The fact that this situation is not dealt with appropriately is, I
believe, simply an oversight. Your example should have undefined behavior.
A type system with non-transitive type-equality breaks all the standard
mathematical models for type theory. (And, yes, I know the C type
system is ugly, but most of it can actually be modeled in pretty
conventional ways.) The category-theoretician in me is befuddled by
what a non-transitive type-equality model could possibly mean.
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com
More information about the Gcc
mailing list