protobuf
protobuf copied to clipboard
Fix warnings when compiling protobuf with C++20
What is the problem?
I got these warnings when compiling gRPC libraries on Linux.
/home/hungptit/working/experiments/_deps/grpc-src/third_party/protobuf/src/google/protobuf/map.cc:124:36: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
124 | const TableEntryPtr* table = table_;
| ^
/home/hungptit/working/experiments/_deps/grpc-src/third_party/protobuf/src/google/protobuf/map.cc:123:24: note: add an explicit capture of 'this' to capture '*this' by reference
123 | const auto loop = [=](auto destroy_node) {
| ^
| , this
1 warning generated.
/home/hungptit/working/experiments/_deps/grpc-src/third_party/protobuf/src/google/protobuf/map.cc:124:36: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
124 | const TableEntryPtr* table = table_;
| ^
/home/hungptit/working/experiments/_deps/grpc-src/third_party/protobuf/src/google/protobuf/map.cc:123:24: note: add an explicit capture of 'this' to capture '*this' by reference
123 | const auto loop = [=](auto destroy_node) {
| ^
| , this
1 warning generated.
We can reproduce these warnings by configuring protobuf using these steps:
cmake ./ -DCMAKE_CXX_COMPILER=clang++ -Dprotobuf_BUILD_TESTS=OFF -DABSL_PROPAGATE_CXX_STD=ON -CMAKE_CXX_STANDARD=20 -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build ./
Solution
- Capture
thisandinputby values.
@mkruskal-google Could you take a look at this simple PR?
@hungptit - Can you see if the changes that recently landed to resolve #17882 fix this issue for you?
Going to close this. Please reopen if https://github.com/protocolbuffers/protobuf/commit/f8bf5eddb4e579c51ff2d98a11fc7dba91aa2950 did not resolve your issue.