[cfe-dev] RFC clang analyzer false positives (for loop)

Daniel Marjamäki via cfe-dev cfe-dev at lists.llvm.org
Thu Aug 25 00:55:52 PDT 2016


Hello!

One more email about false positives.

I see many false positives in code like this:

    int f(int nr) {
      int x;
      for (int i = 0; i < nr; ++i) {
        x = i;
      }
      return x;
    }

Theoretically, if "nr" is less than 0 then the return value will be uninitialized.

As far as I have seen we know that such loops are executed at least once very often. I can't remember a TP where it was possible that such loop code would not be executed.

Can we try to fix this so the analyzer will be silent for the above code? I would like that if the variable is unconditionally written in the loop code there should be no warning.

Best regards,
Daniel Marjamäki

..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62
E-mail:                 Daniel.Marjamaki at evidente.se

www.evidente.se



More information about the cfe-dev mailing list