[Interest] Klocwork errors in Qt

Ramakanth Kesireddy rama.kesi at gmail.com
Tue Dec 3 03:53:14 CET 2019


Hi,

We got below errors in Qt 5.13 using C++ QWidgets while running static code
analysis withKlocwork:

1)Address of a local variable is returned via return statement expression
'QStringBuilder<QStringBuilder<const char*,QString>,const char[2]>(a,
&b).b'.
2)Address of a local variable is returned via return statement expression
'QStringBuilder<QStringBuilder<const char*,QString>,const char[2]>(a, &b).b'
3)Address of a local variable is returned via return statement expression
'QStringBuilder<const char[2],QString>(&a, b).a'.

pointing to the below source @
https://github.com/qt/qtbase/blob/dev/src/corelib/text/qstringbuilder.h

template <typename A, typename B>
QStringBuilder<typename QConcatenable<A>::type, typename
QConcatenable<B>::type>
operator%(const A &a, const B &b)
{
   return QStringBuilder<typename QConcatenable<A>::type, typename
QConcatenable<B>::type>(a, b);
}

We are concatenating two QStrings using % which might lead to the above
errors:
For eg: eventString = eventString % eventState

Do you recommend to use QString(%1%2").arg( eventString ).arg( eventState )
instead to resolve above errors or ignore the Klocwork errors reported?

Another Klocwork error reported is

4)
https://github.com/radekp/qt/blob/master/src/corelib/tools/qsharedpointer_impl.h
 inline Basic(Qt::Initialization) { }
        // ~Basic();
'this->value' is not initialized in this constructor.
List of initiations may be incomplete.

Let me know if it makes sense to further analyze or ignore the errors
reported in Qt?

Best Regards,
Ramakanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20191203/7acc1e25/attachment.html>


More information about the Interest mailing list