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

Delegated creators related rules (S6011,S6003,S6033,S6030) behave inconsistently

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.26
    • Component/s: None
    • Labels:
      None

      Description

      We have multiple rules suggesting replacing manual construction with delegated creator (`push_back(X(...))` vs `emplace_back<X>(...)`). However, the behave differently for regarding corner case types, where such replacement may not be possible because:

      • constructor is private
      • list-initialization is used
      • replacement may be unsafe (resource would be passed)
        Which may lead them to give contradicting suggestions, i..e. circle of replacing `push_back` vs `emplace_back`.

      See test/checks/ReplaceByDelegatedCreatorComparison.cpp for illustrative examples.

        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: