[cfe-commits] [PATCH] Catching large array sizes

Sean Silva silvas at purdue.edu
Sun Jul 22 13:37:31 PDT 2012


Would you mind distilling this explanation into a comment above the assert?

--Sean Silva

On Sun, Jul 22, 2012 at 1:41 PM, Abramo Bagnara
<abramo.bagnara at gmail.com> wrote:
> Il 22/07/2012 20:50, Aaron Ballman ha scritto:
>> This patch is to address PR13271 -- the problem comes from declaring
>> an array that's "too large" within a structure, and then attempting to
>> take the sizeof that structure.  We have an assert in
>> ASTContext::getTypeInfoImpl about the size of constant arrays, but the
>> problem is that this is called when attempting to get the sizeof a
>> structure.  We've already reported the issue to the user about the
>> array being too large by this point, and so the assert triggers.
>>
>> I'm not convinced the assert is required here, so I've removed it in
>> this patch.  However, I'm also not convinced the assert is invalid and
>> am open to suggestions as to other ways to handle the error.
>
> The assertion is needed because unfortunately type size are currently
> evaluated in bits (and not in bytes) inside an uint64_t.
>
> This means that perfectly valid sizeof >= 1 << 61 are not evaluatable
> and clang silently produced invalid code. The assertion was introduced
> to avoid that.
>
> The proper fix should be to make clang able to evaluate correctly type
> size in bytes also when it is >= 1 << 61.
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list