[Bug] Build fails with protobuf 36.1 under -Werror=unused-result
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 62/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cmake, cpp
- Ambito
- build-system
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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!
- Lingua principale
- C++
- Stelle
- 72
- Fork
- 93
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/pulsar-client-cpp
-
[Bug] MessageTest fails to build with GCC 15.3.0 and 16.2.1 (-Werror=stringop-truncation)Forse già presa @davlgd l’ha presa 3 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 25/100
apache/pulsar-client-cpp#621 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
apache/pulsar-client-cpp#620 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
apache/pulsar-client-cpp#619 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
apache/pulsar-client-cpp#618 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
apache/pulsar-client-cpp#617 ·
Tutte le issue di apache/pulsar-client-cpp
Issue simili
-
`BLMPOP` with COUNT 0 or numkeys 0 hangsForse già presa @ggyuchive l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
gObjectFullbrightAlphaMaskProgram in newview/llviewershadermgr.cpp is defined but never initializedApertabug triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
secondlife/viewer#6620 ·
I maintainer di solito rispondono entro 1 giorno
-
bug core p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
RunanywhereAI/runanywhere-sdks#1258 ·
I maintainer di solito rispondono entro 1 giorno
-
ripwire-router skill: stale language list (15 vs 26 supported; Elixir/PHP/Kotlin wrongly listed as unsupported)Forse già presa @joyful-ii-V-I l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
redhat-et/ripwire#521 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno