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

S6023: Fix false-positive when different optional are checked and derefenced

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.15
    • Fix Version/s: 6.26
    • Component/s: C++
    • Labels:
      None

      Description

      The issue is raised if the different optional object is checked for being engaged and dereferenced. For example it is raised on following code:

      void testTwoOptionals(const std::optional<int>& o1, const std::optional<int>& o2) {
        int i = 0;
        if (o1.has_value()) {
          i = o2.value();
        } else {
          i = -1;
        }
        (void)i;
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tomasz.kaminski Tomasz Kamiński
              Reporter:
              tomasz.kaminski Tomasz Kamiński
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: