[Bug] Build fails with protobuf 36.1 under -Werror=unused-result
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 62/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- cmake, cpp
- 領域
- build-system
調査の方向性
The unused-result errors are at lib/Commands.cc lines 129, 238, 250, 880 and 923, lib/MessageId.cc:87 and lib/ProtobufNativeSchema.cc:49; tests/ProtobufNativeSchemaTest.cc:114 and :123 raise the same warning. Start by reproducing with cmake --build build -- -k against protobuf 36.1. Done means the library compiles under -Werror with protobuf 36.1 because each listed call checks its return value and handles failure, and the MessageTest strncpy failure in #621 is out of scope.
索引モデルが issue の本文から書いたものです。
説明
Search before asking
- I searched in the issues and found nothing similar.
Version
pulsar-client-cpp 4.2.0 on Arch Linux (x86_64), GCC 16.2.1, protobuf 36.1, abseil-cpp 20260817.0. The same calls are present on main at f71d7e99019d58b1d11858f05ff0dc83b718627b (source inspection; in lib/Commands.cc they are at lines 130, 239, 251, 936 and 979).
Minimal reproduce step
With protobuf 36.1 and the other dependencies installed:
cmake -S . -B build -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS=-O2
cmake --build build
The library compilation fails before the test target is built.
What did you expect to see?
The library builds.
What did you see instead?
Diagnostics collected from 4.2.0 with the one-line MessageTest fix proposed in #622 applied, using cmake --build build -- -k (Unix Makefiles generator). The library call sites were unchanged; line numbers below are from 4.2.0.
lib/Commands.cc:129:25: error: ignoring return value of 'bool google::protobuf::MessageLite::SerializeToArray(void*, int) const', declared with attribute 'nodiscard' [-Werror=unused-result]
lib/Commands.cc:238:25: error: ignoring return value of 'bool google::protobuf::MessageLite::SerializeToArray(void*, int) const', declared with attribute 'nodiscard' [-Werror=unused-result]
lib/Commands.cc:250:30: error: ignoring return value of 'bool google::protobuf::MessageLite::SerializeToArray(void*, int) const', declared with attribute 'nodiscard' [-Werror=unused-result]
lib/Commands.cc:880:30: error: ignoring return value of 'bool google::protobuf::MessageLite::SerializeToArray(void*, int) const', declared with attribute 'nodiscard' [-Werror=unused-result]
lib/Commands.cc:923:28: error: ignoring return value of 'bool google::protobuf::MessageLite::ParseFromArray(const void*, int)', declared with attribute 'nodiscard' [-Werror=unused-result]
lib/MessageId.cc:87:29: error: ignoring return value of 'bool google::protobuf::MessageLite::SerializeToString(std::string*) const', declared with attribute 'nodiscard' [-Werror=unused-result]
lib/ProtobufNativeSchema.cc:49:39: error: ignoring return value of 'bool google::protobuf::MessageLite::SerializeToArray(void*, int) const', declared with attribute 'nodiscard' [-Werror=unused-result]
With -Wno-error=unused-result, the build also reports the same warnings in tests/ProtobufNativeSchemaTest.cc:114 (SerializeToArray) and :123 (ParseFromArray).
Anything else?
In protobuf 36.1, these methods are annotated [[nodiscard]] (message_lite.h, port_def.inc). The project's -Werror setting turns the unused-result diagnostics at the listed call sites into build errors. The listed call sites do not check the returned success value. Adding -Wno-error=unused-result downgrades these diagnostics to warnings; it does not resolve the separate MessageTest strncpy build failure tracked in #621.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- 主要言語
- C++
- スター
- 72
- フォーク
- 93
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/pulsar-client-cpp のほかの issue
-
[Bug] MessageTest fails to build with GCC 15.3.0 and 16.2.1 (-Werror=stringop-truncation)対応中かも @davlgd が 3 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
apache/pulsar-client-cpp#621 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
apache/pulsar-client-cpp#620 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
apache/pulsar-client-cpp#619 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
apache/pulsar-client-cpp#618 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
apache/pulsar-client-cpp#617 ·
apache/pulsar-client-cpp の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
eclipse-score/lifecycle#929 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
colbymchenry/codegraph#3223 ·
メンテナーはふだん 1 日以内に返信