Issue 99811
Summary clang-tidy 19: check bugprone-unused-return-value shows many false-positive results
Labels clang-tidy
Assignees
Reporter pkl97
    Some change between clang 18 and 19 made clang-tidy check bugprone-unused-return-value report lots of false-positive results.

It seems the internal function matching now works differently (and incorrect).

E.g. this Qt example program shows the problem:
```c++
#include <QtCore/QString>
#include <QtWidgets/QApplication>
#include <QtGui/QFont>
#include <QtWidgets/QPushButton>

int main(int argc, char** argv)
{
 QApplication a(argc,argv);

    QPushButton quit(QString::fromUtf8("Hello World"));
    quit.resize(175,30);
 quit.setFont(QFont(QString::fromUtf8("Times"),18,QFont::Bold));
 QObject::connect(&quit,&QAbstractButton::clicked,&a,&QCoreApplication::quit);
 quit.show();
    return a.exec();
}
```

clang-tidy reports this warning:
```bash
main.cpp:13:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors [bugprone-unused-return-value]
   13 | QObject::connect(&quit,&QAbstractButton::clicked,&a,&QCoreApplication::quit);
 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

In clang 18 no such warning is emitted. And QObject::connect() is not even the target of the check. According to the [documentation of the check](https://clang.llvm.org/extra/clang-tidy/checks/bugprone/unused-return-value.html) the global system function ::connect() is meant.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to