From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Mitchell To: mrs@wrs.com Cc: jbuck@synopsys.com, gcc@gcc.gnu.org, rms@gnu.org Subject: Re: type based aliasing again Date: Thu, 30 Sep 1999 18:02:00 -0000 Message-ID: <19990909144240H.mitchell@codesourcery.com> References: <199909092125.OAA15998@kankakee.wrs.com> X-SW-Source: 1999-09n/msg00373.html Message-ID: <19990930180200.9mLhShZhVxsPirJOMbEEn21NbQ4KlKpgduVBfcWUY2s@z> >>>>> "Mike" == Mike Stump writes: >> From: Mark Mitchell Date: Wed, 08 Sep >> 1999 20:29:57 -0700 >> There will be cases where A will pessimize code that does not >> have undefined behavior. Mike> I was trying to envision this. Do you have an example? I Mike> was thinking Joe meant doing this is cases were we can prove Mike> that they in fact do alias, but for which the types don't Mike> match. Lessor cases were we cannot prove they alias, would Mike> not issue a warning. How about: void f (int *x, int *y) { void *v = malloc (4); *x = 1; if (*x) *((int *) v) = 3; *y = !*x; if (!*x) *((float *) v) = 7.0; } Here, we can conclude that `*y = *!x' does not modify `*x'. Why? Because that would change the value of *x, which would mean that we would access `*v' illegally. Since that would have undefined behavior, we can decide that `y' and `x' do not point at the same place. A bit theoretical, I admit. But, a less contrived example is probably also possible along these lines. -- Mark Mitchell mark@codesourcery.com CodeSourcery, LLC http://www.codesourcery.com