Menu

New FP regression on Head over 2.7 release

dp11
2022-04-25
2022-05-09
  • dp11

    dp11 - 2022-04-25
    int main () {
       int screendata[11];
       int *dp = screendata;
       int height = font->height;
       int step = 2;
       for (int i = 0; i < (height * step); i += step) {
          *dp++ = 0;
       }
    
      for (y = 0; y < height; y++) {
         if (screendata[y]) {
            break;
         }
      }
    
       return 0;
    }
    

    The above gives :

    ../FP23c.c:12:7: error: Uninitialized variable: screendata [uninitvar]
    if (screendata[y]) {
    ^
    ../FP23c.c:7:22: note: Assuming condition is false
    for (int i = 0; i < (height * step); i += step) {
    ^
    ../FP23c.c:12:7: note: Uninitialized variable: screendata
    if (screendata[y]) {

    Which I think is a new false positive. 2.7 didn't give a false positive

     

    Last edit: dp11 2022-04-25
  • CHR

    CHR - 2022-04-26

    Thanks for reporting, I have created a ticket: https://trac.cppcheck.net/ticket/11006

     
  • dp11

    dp11 - 2022-05-07

    Thanks for the fix of 11006.

    Unfortunately my original case still fails before being cut down . New test case here
    void f() { int a[11]; int *p = a; int height = 10; int step 1; for (int i = 0; i < (height * step); i += step) *p++ = 0; for (int i = 0; i < height; i++) if (a[i]) {} }

     
    • CHR

      CHR - 2022-05-09

      There is no FP with https://github.com/chrchr-github/cppcheck/commit/c71033548f57abee39faf9ee9776c653a1a5d4eb for

      void f() {
          int a[11];
          int *p = a;
          int height = 10;
          int step = 1;
          for (int i = 0; i < (height * step); i += step)
              *p++ = 0;
          for (int i = 0; i < height; i++) 
              if (a[i]) {} 
      }
      
       
      • dp11

        dp11 - 2022-05-09

        Sorry something went wrong with cut and paste

        void f(int step) {
                int a[11];
                int *p = a;
                int height = 10;
                for (int i = 0; i < (height * step); i += step)
                        *p++ = 0;
                for (int i = 0; i < height; i++)
                        if (a[i]) {}
        }
        

        This gives :

        Checking ../FP6.c ...
        ../FP6.c:8:21: error: Uninitialized variable: a [uninitvar]
                        if (a[i]) {}
                            ^
        ../FP6.c:5:27: note: Assuming condition is false
                for (int i = 0; i < (height * step); i += step)
                                  ^
        ../FP6.c:8:21: note: Uninitialized variable: a
                        if (a[i]) {}
        
         
        • CHR

          CHR - 2022-05-09
           
  • Paul Fultz

    Paul Fultz - 2022-05-07

    int step 1; is not valid C++.

     
  • dp11

    dp11 - 2022-05-07

    Sorry thats a typo should be int step =1;

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.