In this case, the integer in APInt is 64 bits (returned from CAT->getSize()), while the type given is sized as 32 bits (Context.IntTy).  A truncate instead of an extend is required.  Is getSize() returning with a larger bit width than necessary or can the array index exceed the size of an int?  Also, if we do proceed this way, the new integer literal creation method I wrote would not be used.  Will it still be useful or should I remove it?<br>
<br><div class="gmail_quote">On Tue, Apr 26, 2011 at 5:50 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Richard,<br>
<br>
Thanks for catching this, and my apologies for the delay in getting back<br>
to you.<br>
<div class="im"><br>
On Fri, 22 Apr 2011 21:26, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:<br>
> The code for range-based for-loops makes a bad integer literal expression<br>
> which has a mis-match between the size of the literal and the integer<br>
> type. This causes an assert to be thrown when IsIntegerConstant() is<br>
> called on it. For this patch,<br>
><br>
> 1) the assert that checks bit width is copied from IsIntegerConstant()<br>
> into the integer literal constructor.<br>
<br>
</div>This looks fine.<br>
<div class="im"><br>
> 2) a new static function was written so that it automatically selects<br>
the > correct size integer and returns a proper integer literal<br>
><br>
> 3) the range-based for-loops now use the function in #2 to get the right<br>
> integer literal<br>
<br>
</div>I'd prefer for us to always use ptrdiff_t[*] for this (which is guaranteed<br>
to be big enough), and to extend the integer to fit, rather than picking a<br>
'big enough' type based on the integer's value.<br>
<br>
[*] I think this actually needs to be the appropriate ptrdiff_t for the<br>
address space of the array.<br>
<br>
Thanks!<br>
<font color="#888888">Richard<br>
<br>
</font></blockquote></div><br>