[PATCH] D52750: [Diagnostics] Check for integer overflow in array size expressions

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 11 13:49:59 PDT 2018


xbolva00 added a comment.

In https://reviews.llvm.org/D52750#1261746, @Rakete1111 wrote:

> Nah, you don't even need to call `EvaluateForOverflow` I believe. :) Have a look overflow evaluation is done.


Well..

  if (!getLangOpts().CPlusPlus11 && E->isIntegerConstantExpr(Context)) {
    if (Result) {
      *Result = E->EvaluateKnownConstInt(Context); // here

}

and 
 char a[2147483642 * 3];

Result->getBitWidth() reports 32.  I don't know how to detect there if overflow or not :/ I have already spent some time to solve this, but still no good solution. Possibly I would abandon this patch.


https://reviews.llvm.org/D52750





More information about the cfe-commits mailing list