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

C++11 Rule: Default capture should not be used

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.12
    • Component/s: C++, Rules
    • Labels:
      None

      Description

      See https://google.github.io/styleguide/cppguide.html#Lambda_expressions

      struct S {
        void member(Foo);
      
        void fun() {
          Foo foo;
          ...
          // if lambda is invoked after the function returns - both "foo" and the enclosing object could have been destroyed:
          executor->Schedule([&] { member(foo); });
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ann.campbell.2 Ann Campbell
              Reporter:
              evgeny.mandrikov Evgeny Mandrikov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: