<div dir="ltr">+aliasing people<div><br></div><div>I *think* this is valid, because the rules have always been described to me in terms of underlying storage type, and not access path. These are all ints, so all loads and stores can alias.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 9, 2014 at 3:07 PM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">----- Original Message -----<br>
> From: "Tim Northover" <<a href="mailto:t.p.northover@gmail.com">t.p.northover@gmail.com</a>><br>
> To: "Jonas Wagner" <<a href="mailto:jonas.wagner@epfl.ch">jonas.wagner@epfl.ch</a>><br>
> Cc: "cfe-dev Developers" <<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>>, "LLVM Developers Mailing List" <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>><br>

> Sent: Friday, August 8, 2014 6:54:50 AM<br>
> Subject: Re: [cfe-dev] [LLVMdev] For alias analysis, It's gcc too aggressive or LLVM need to improve?<br>
><br>
> > your C program invokes undefined behavior when it dereferences<br>
> > pointers that<br>
> > have been converted to other types. See for example<br>
> > <a href="http://stackoverflow.com/questions/4810417/c-when-is-casting-between-pointer-types-not-undefined-behavior" target="_blank">http://stackoverflow.com/questions/4810417/c-when-is-casting-between-pointer-types-not-undefined-behavior</a><br>

><br>
> I don't think it's quite that simple.The type-based aliasing rules<br>
> come from 6.5p7 of C11, I think. That says:<br>
><br>
> "An object shall have its stored value accessed only by an lvalue<br>
> expression that has one of<br>
> the following types:<br>
>   + a type compatible with the effective type of the object,<br>
>   [...]<br>
>   + an aggregate or union type that includes one of the<br>
>   aforementioned<br>
> types among its members [...]"<br>
><br>
> That would seem to allow this usage: aa (effective type "int") is<br>
> being accessed via an lvalue "ptr[i]->index" of type "int".<br>
><br>
> The second point would even seem to allow something like "ptr[i] =<br>
> ..." if aa was declared "int aa[2];", though that seems to be going<br>
> too far. It also seems to be very difficult to pin down a meaning<br>
> (from the standard) for "a->b" if a is not a pointer to an object<br>
> with<br>
> the correct effective type. So the entire area is probably one that's<br>
> open to interpretation.<br>
><br>
> I've added cfe-dev to the list; they're the *professional* language<br>
> lawyers.<br>
<br>
</div></div>Coincidentally, this also seems to be PR20585 (adding Jiangning Liu, the reporter of that bug, to this thread too).<br>
<br>
 -Hal<br>
<div class="im HOEnZb"><br>
><br>
> Cheers.<br>
><br>
> Tim.<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
><br>
<br>
</div><span class="HOEnZb"><font color="#888888">--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>