Created attachment 21348
Minimal example showing false positive of NewDeleteLeaks check
The NewDeleteLeaks check thinks that QTimer::singleShot leaks the lambda
function object, but internally Qt reference counts the object and takes care
of deleting it.
The attached QtSingleShotNewDeleteLeakFalsePositive.cpp file demonstrates the
error:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:154:5: error: Potential
memory leak [clang-analyzer-cplusplus.NewDeleteLeaks,-warnings-as-errors]
}
^
/home/.../QtSingleShotNewDeleteLeakFalsePositive.cpp:5:5: note: Calling
'QTimer::singleShot'
QTimer::singleShot(0, [=] {});
^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:125:9: note: Calling
'QTimer::singleShot'
singleShot(interval, defaultTypeFor(interval), nullptr, slot);
^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:152:24: note: Memory is
allocated
new QtPrivate::QFunctorSlotObject<Func1, 0,
^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:154:5: note: Potential memory
leak
}
^
This is with Qt 5.9.5 on Ubuntu 18.04. I do not see the issue on Windows with
the same Qt version.
QtSingleShotNewDeleteLeakFalsePositive.cpp
(104 bytes, text/x-c++src)