[Bug] Build fails with protobuf 36.1 under -Werror=unused-result
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 62/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- cmake, cpp
- Área
- build-system
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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!
- Lenguaje dominante
- C++
- Estrellas
- 72
- Forks
- 93
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/pulsar-client-cpp
-
[Bug] MessageTest fails to build with GCC 15.3.0 and 16.2.1 (-Werror=stringop-truncation)Posiblemente ocupada @davlgd la tomó hace 3 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 25/100
apache/pulsar-client-cpp#621 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
apache/pulsar-client-cpp#620 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
apache/pulsar-client-cpp#619 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
apache/pulsar-client-cpp#618 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
apache/pulsar-client-cpp#617 ·
Todos los issues de apache/pulsar-client-cpp
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NVIDIA-RTX/NRI#307 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
eclipse-score/lifecycle#929 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día