<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 30, 2014 at 9:46 AM, Jonas Maebe <span dir="ltr"><<a href="mailto:jonas.maebe@elis.ugent.be" target="_blank">jonas.maebe@elis.ugent.be</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
The GEP takes the address of the 5th element (= offset 4) of your "char t[4]". It's not entirely clear to me from the description of "inbounds" whether this means the the GEP results in a poison value or not, but it definitely looks wrong.</blockquote>
<div><br></div><div>I believe LLVM IR allows you to GEP from inside of one field into the next, but I would defer to experts.</div><div><br></div><div>The constant folder is what creates this, and it totally ignores the element index when folding a zero initialized array type:</div>
<div><br></div><div><div><div>Constant *ConstantAggregateZero::getSequentialElement() const {</div><div> return Constant::getNullValue(getType()->getSequentialElementType());</div><div>}</div></div></div><div><div>Constant *ConstantAggregateZero::getElementValue(unsigned Idx) const {</div>
<div> if (isa<SequentialType>(getType()))</div><div> return getSequentialElement(); // Doesn't pass in Idx or check bounds.</div><div> return getStructElement(Idx);</div><div>}</div></div><div><br></div><div>
Looks like a bug to me.</div></div></div></div>