On Monday, 2 December 2019 18:53:14 PST Ramakanth Kesireddy wrote: > 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?
No, there's no need. QStringBuilder works just fine and has been working for over 10 years. Either there's a problem somewhere in your code that you didn't show to us or it s a Klocwork false positive. Hint: do not use "auto" to detect the type when QStringBuilder is active. Don't write: auto str = a + b; instead, write: QString str = a + b; > 4) > https://github.com/radekp/qt/blob/master/src/corelib/tools/qsharedpointer_im > pl.h> > inline Basic(Qt::Initialization) { } > > // ~Basic(); > > 'this->value' is not initialized in this constructor. > List of initiations may be incomplete. The only value in the Qt::Initialization enum is Qt::Uninitialized. So that tmeans this is intentional. Ignore this report. PS: the links above seem to be Qt 4. That's obviously not supported. My answers are about Qt 5. Both QStringBuilder and QSharedPointer have received a few fixes in the last 7 years. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel System Software Products _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest