Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-1905

Fix false-positive in S2259

    XMLWordPrintable

    Details

      Description

      1. [[noreturn]] void bug(char const* str);
        [[noreturn]] void bug(int code);
        
        #define MY_ASSERT(b) { if (!(b)) bug("null"); }
        
        void fp100(int* ptr) {
          MY_ASSERT(ptr);
          *ptr; // no issue expected here
        }
        
      2. struct A {
          int size();
        };
        
        template<typename... Args>
        [[noreturn]] void throwSTD(Args&&... args);
        
        
        void falsePositive( A * str ) {
          if ( str == nullptr ) {
            throwSTD("str == nullptr");
          }
          str->size(); // false positive
        }
        

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              massimo.paladin Massimo PALADIN
              Reporter:
              massimo.paladin Massimo PALADIN
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: