This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: IMA vs tree-ssa


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]