Most people use clang with assertions disabled, so this doesn't really solve the underlying problem.<div><br></div><div>Reid<br><br><div class="gmail_quote">On Sun, Dec 11, 2011 at 3:55 AM, Abramo Bagnara <span dir="ltr"><<a href="mailto:abramo.bagnara@gmail.com">abramo.bagnara@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Il 10/12/2011 22:41, David Blaikie ha scritto:<br>
<div class="im">> Did you mean to attach a patch showing the assert you intend to add?<br>
<br>
</div>I believed it was not needed, but I've attached it now for review.<br>
<br>
With that patch applied the following testcase (specific for 64 bit<br>
architecture) now triggers the assertion instead to be horribly miscompiled.<br>
<br>
#include <stdio.h><br>
<br>
typedef int x[1UL<<59];<br>
<br>
int main() {<br>
  printf("%lu\n", sizeof(x));<br>
<div class="HOEnZb"><div class="h5">}<br>
<br>
<br>
> On Sat, Dec 10, 2011 at 12:52 PM, Abramo Bagnara<br>
> <<a href="mailto:abramo.bagnara@gmail.com">abramo.bagnara@gmail.com</a>> wrote:<br>
>><br>
>> Ping.<br>
>><br>
>>><br>
>>> In ASTContext:::getTypeInfo(const Type *T) const we have:<br>
>>><br>
>>>   uint64_t Width=0;<br>
>>><br>
>>>   case Type::ConstantArray: {<br>
>>>     const ConstantArrayType *CAT = cast<ConstantArrayType>(T);<br>
>>><br>
>>>     std::pair<uint64_t, unsigned> EltInfo =<br>
>>> getTypeInfo(CAT->getElementType());<br>
>>>     Width = EltInfo.first*CAT->getSize().getZExtValue();<br>
>>><br>
>>> But this multiplication can overflow (because for reasons that I don't<br>
>>> known getTypeInfo return width specified in bits).<br>
>>><br>
>>> If there are no objections I'd add an assert: probably we'll induce some<br>
>>> crashes, but I believe that this would be *far* better than to<br>
>>> miscompile the code (and assertions will be triggered only when code<br>
>>> would be miscompiled).<br>
>>><br>
</div></div><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></blockquote></div><br></div>