Skip to content

Conversation

@firewave
Copy link
Collaborator

@firewave firewave commented Dec 8, 2025

No description provided.

@firewave

This comment was marked as resolved.

@firewave firewave force-pushed the cxx20 branch 2 times, most recently from 774d19d to 7a010b5 Compare December 29, 2025 19:16
@firewave firewave changed the title pathmatch.cpp: fixed -Wdeprecated-this-capture Clang C++20 warning fixed C++20 build Dec 29, 2025
@firewave firewave changed the title fixed C++20 build fixed #14347 - fixed Clang warnings in C++20 build Dec 29, 2025
@firewave
Copy link
Collaborator Author

The CI jobs will not trigger the warnings which have been fixed by this. A Clang build is implicitly performed by the clang-tidy job. We could switch that job to a higher standard (C++23 even) and adjust the configuration accordingly. This would also allow us to introduce some more conditional modernizations.

@firewave firewave force-pushed the cxx20 branch 3 times, most recently from 2260091 to c107e0e Compare December 29, 2025 22:33
@firewave
Copy link
Collaborator Author

The CI jobs will not trigger the warnings which have been fixed by this. A Clang build is implicitly performed by the clang-tidy job.

not true - macOS obviously uses Clang...

@firewave
Copy link
Collaborator Author

The C++20 builds fails for macOS:

/Users/runner/work/cppcheck/cppcheck/cmake.output/gui/test/projectfile/moc_testprojectfile.cpp:84:1: error: 'constinit' specifier is incompatible with C++ standards before C++20 [-Werror,-Wc++20-compat]
   84 | Q_CONSTINIT const QMetaObject TestProjectFile::staticMetaObject = { {
      | ^
/opt/homebrew/opt/qt/lib/QtCore.framework/Headers/qcompilerdetection.h:1409:23: note: expanded from macro 'Q_CONSTINIT'

example:
```
/home/user/CLionProjects/cppcheck/lib/pathmatch.cpp:37:37: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
   37 |         return match(pattern, path, mBasepath, mode, mSyntax);
      |                                     ^
/home/user/CLionProjects/cppcheck/lib/pathmatch.cpp:36:63: note: add an explicit capture of 'this' to capture '*this' by reference
   36 |     return std::any_of(mPatterns.cbegin(), mPatterns.cend(), [=] (const std::string &pattern) {
      |                                                               ^
      |                                                                , this
```
@firewave firewave marked this pull request as ready for review January 12, 2026 01:40
@sonarqubecloud
Copy link

auto *action = new QAction(tr("No tag"), tagMenu);
tagMenu->addAction(action);
connect(action, &QAction::triggered, [=]() {
connect(action, &QAction::triggered, [EXPLICIT_THIS]() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this be rewritten so it's compatible both with c++20 and c++14 ? [this] ?

auto *action = new QAction(tagstr, tagMenu);
tagMenu->addAction(action);
connect(action, &QAction::triggered, [=]() {
connect(action, &QAction::triggered, [EXPLICIT_THIS]() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would [tagstr, this] work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants