[PATCH] When an array is created that is too large, lower its size to the maximum allowable size.

Richard Smith richard at metafoo.co.uk
Wed May 15 18:00:06 PDT 2013


On Wed, May 15, 2013 at 5:54 PM, Richard Trieu <rtrieu at google.com> wrote:

>
>
> ================
> Comment at: lib/Sema/SemaType.cpp:1564-1567
> @@ -1555,2 +1563,6 @@
>            << ArraySize->getSourceRange();
> +        // Set array size to largest allowable size.
> +        getMaxArraySize(Context, T,
> ConstantArrayType::getMaxSizeBits(Context),
> +                        ConstVal);
> +      }
>      }
> ----------------
> Richard Smith wrote:
> > How about just returning QualType() here? An invalid type should do a
> better job of suppressing follow-on diagnostics than an
> array-of-unexpected-size.
> Returning QualType() also would prevent the crash, however it also causes
> a new error to be emitted.  "initializer element is not a compile-time
> constant" on __builtin_offsetof(struct Chunk2, data).


I think that's basically an unrelated issue: constant expression evaluation
doesn't have a way to say "evaluation failed due to an error which has
already been diagnosed". I'm OK with that additional diagnostic (with a
FIXME to remove it).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130515/4ef0ed09/attachment.html>


More information about the cfe-commits mailing list