Fix and re-enable C++20 -Wdeprecated-this-capture warnings
Categories
(Firefox Build System :: General, task, P3)
Tracking
(firefox149 fixed)
| Tracking | Status | |
|---|---|---|
| firefox149 | --- | fixed |
People
(Reporter: cpeterson, Assigned: cpeterson)
References
Details
Attachments
(11 files)
|
7.15 KB,
text/plain
|
Details | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
The implicit capture of *this when the capture default is = is deprecated in C++20:
https://en.cppreference.com/w/cpp/language/lambda#Lambda_capture
See the attached log file for the 48 -Wdeprecated-this-capture warnings currently reported in mozilla-central.
However, due to inconsistencies in how clang and gcc handle explicit this captures in -std=c++17 mode, we can't fix these warnings (without ugly #ifdefs) to make this code compatible with both clang and gcc until after we build as -std=c++20 by default (bug 1768116).
class C {
void memberFunction() {}
void testCapture() {
[=]() { memberFunction(); }();
// Implicit capture of *this is OK in clang and gcc -std=c++17.
// -Wdeprecated-this-capture warning in clang -std=c++20.
// -Wdeprecated warning in gcc -std=c++20.
[=, this]() { memberFunction(); }();
// Explicit capture of *this is OK in clang and gcc -std=c++20.
// -Wc++20-extensions warning in clang -std=c++17.
// Error in gcc -std=c++17 with no way to suppress it.
}
};
| Assignee | ||
Updated•3 years ago
|
| Assignee | ||
Comment 1•3 years ago
|
||
These -Wdeprecated-this-capture warnings only reported when compiled with -std=c++20. In the meantime, these warnings were downgraded from errors to warnings in bug 1781001 so fixing these warnings doesn't need to block updating to C++20.
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 2•1 month ago
|
||
build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 636: implicit capture of 'this' with a capture default of '=' is deprecated
build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 639: implicit capture of 'this' with a capture default of '=' is deprecated
build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 660: implicit capture of 'this' with a capture default of '=' is deprecated
build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 663: implicit capture of 'this' with a capture default of '=' is deprecated
| Assignee | ||
Comment 3•1 month ago
|
||
dom/clients/manager/ClientHandleOpParent.cpp:89:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/ChannelMediaDecoder.cpp:406:17 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/MediaCache.cpp:1978:9 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:1034:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:1050:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:1283:9 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:561:11 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:586:15 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:635:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:765:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:811:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:897:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:915:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:946:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandler.cpp:993:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:121:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:132:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:143:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:156:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:185:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:227:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:240:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:260:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:279:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:296:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:308:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:334:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:346:13 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
dom/media/webrtc/jsapi/MediaTransportHandlerIPC.cpp:93:14 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
| Assignee | ||
Comment 4•1 month ago
|
||
toolkit/components/extensions/webrequest/StreamFilterParent.cpp:338:7 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
toolkit/components/extensions/webrequest/StreamFilterParent.cpp:361:7 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
toolkit/components/extensions/webrequest/StreamFilterParent.cpp:420:5 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
toolkit/components/extensions/webrequest/StreamFilterParent.cpp:426:7 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
toolkit/components/extensions/webrequest/StreamFilterParent.cpp:615:11 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
toolkit/components/extensions/webrequest/StreamFilterParent.cpp:633:11 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
toolkit/components/extensions/webrequest/StreamFilterParent.cpp:699:7 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
| Assignee | ||
Comment 5•1 month ago
|
||
gfx/thebes/gfxPlatformFontList.cpp:1707:20 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
gfx/thebes/gfxPlatformFontList.cpp:1942:40 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
| Assignee | ||
Comment 6•1 month ago
|
||
image/decoders/nsBMPDecoder.cpp:435:20 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
image/decoders/nsGIFDecoder2.cpp:454:20 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
image/decoders/nsICODecoder.cpp:644:20 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
image/decoders/nsIconDecoder.cpp:38:34 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
image/decoders/nsJPEGDecoder.cpp:194:34 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
image/decoders/nsJXLDecoder.cpp:79:34 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
image/decoders/nsPNGDecoder.cpp:362:34 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
| Assignee | ||
Comment 7•1 month ago
|
||
ipc/ipdl/test/gtest/TestAsyncReturns.cpp:64:9: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
ipc/ipdl/test/gtest/TestAsyncReturns.cpp:72:9: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
ipc/ipdl/test/gtest/TestHangs.cpp:134:1: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
| Assignee | ||
Comment 8•1 month ago
|
||
layout/forms/HTMLSelectEventListener.cpp:739:23 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
layout/generic/nsFlexContainerFrame.cpp:3796:18 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
layout/generic/nsFlexContainerFrame.cpp:3802:18 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
layout/style/FontFaceImpl.cpp:466:5 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
| Assignee | ||
Comment 9•1 month ago
|
||
netwerk/ipc/DocumentLoadListener.cpp:975:15: error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-Wdeprecated-this-capture]
netwerk/protocol/http/nsHttpConnectionMgr.cpp:3011:9 [-Wdeprecated-this-capture] implicit capture of 'this' with a capture default of '=' is deprecated
| Assignee | ||
Comment 10•1 month ago
|
||
widget/android/GeckoEditableSupport.cpp:653:21: error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-Wdeprecated-this-capture]
widget/android/GeckoEditableSupport.cpp:748:7: error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-Wdeprecated-this-capture]
| Assignee | ||
Comment 11•1 month ago
|
||
And re-enable gcc's -Wdeprecated warnings, which were only disabled
because gcc didn't have a more precise flag to disable its warnings
about C++20 deprecated this captures.
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Comment 12•1 month ago
|
||
Comment 13•1 month ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/60c0db17b1a8
https://hg.mozilla.org/mozilla-central/rev/2616ebcc10bb
https://hg.mozilla.org/mozilla-central/rev/6792c2db86a0
https://hg.mozilla.org/mozilla-central/rev/a906e032683a
https://hg.mozilla.org/mozilla-central/rev/74b9a73893af
https://hg.mozilla.org/mozilla-central/rev/e3ac82aac61c
https://hg.mozilla.org/mozilla-central/rev/04f668b3d2e0
https://hg.mozilla.org/mozilla-central/rev/66fc6fd04c98
https://hg.mozilla.org/mozilla-central/rev/2105d99307d1
https://hg.mozilla.org/mozilla-central/rev/91ec7dfaaecc
Description
•