[clazy] [Bug 405850] New: connect-3arg-lambda should not warn in main()

David Faure bugzilla_noreply at kde.org
Mon Mar 25 08:41:34 GMT 2019


https://bugs.kde.org/show_bug.cgi?id=405850

            Bug ID: 405850
           Summary: connect-3arg-lambda should not warn in main()
           Product: clazy
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: unassigned-bugs at kde.org
          Reporter: faure at kde.org
                CC: smartins at kde.org
  Target Milestone: ---

SUMMARY
connect-3arg-lambda warns about possible issues with the lifetime of captured
variables (by reference). This leads to false positives when not going back to
the event loop (e.g. unittests using job.exec()) or in main() where there's no
lifetime issues.

This bug report is about main().

STEPS TO REPRODUCE
Run clazy on any akonadi unittest which uses QTEST_AKONADIMAIN(MyObject)
or do this directly:

    int result = 0; \
        QTimer::singleShot(0, [argc, argv, &result]() { \
            TestObject tc; \
            result = QTest::qExec(&tc, argc, argv); \
            qApp->quit(); \
        }); \
        app.exec(); \

OBSERVED RESULT

    Explanation for clazy-connect-3arg-lambda
    ./tests/auto/sugarcrmresource/test_sugarcrmresource.cpp
        line 585: QTEST_AKONADIMAIN(TestSugarCRMResource)
        => Pass a context object as 2nd singleShot parameter


EXPECTED RESULT

    No warning in main()
    or more generally, no warning when followed by a call to .exec() but that
seems a little bit too black magic, possibly?

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Unassigned-bugs mailing list