Skip to content

java_generator.cpp:184:33: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'google::protobuf::internal::DescriptorStringView'... #21302

Open
@vorburger

Description

@vorburger

What version of protobuf and what language are you using?

Version: 30.2
Language: Java

What operating system (Linux, Windows, ...) and version?

Fedora Linux Workstation 41

What runtime / compiler are you using (e.g., python version or gcc version)

gcc --version
gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)

What did you do?
Steps to reproduce the behavior:

  1. Take build(deps): bump protobuf from 29.2 to 30.2, and remove rules_apple enola-dev/enola#1281
  2. Run bazelisk build //... (on Fedora Linux Workstation 41)
  3. See error

What did you expect to see

"{ Fast, Correct } — Choose two"

What did you see instead?

ERROR: /home/vorburger/.cache/bazel/_bazel_vorburger/a3cf8df34f0c7a76e9926daaad9ffbf4/external/grpc-java+/compiler/BUILD.bazel:6:10: Compiling compiler/src/java_plugin/cpp/java_generator.cpp [for tool] failed: (Exit 1): gcc failed: error executing CppCompile command (from target @@grpc-java+//compiler:grpc_java_plugin) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 115 arguments skipped)
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:184:33: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'}
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:188:49: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'}
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:192:28: error: no match for 'operator+' (operand types are 'const char [5]' and 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'})
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:196:51: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'}
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:407:74: error: converting to 'std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >' from initializer list would use explicit constructor 'constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = const char (&)[8]; _U2 = std::basic_string_view<char>; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = false; _T1 = const std::__cxx11::basic_string<char>; _T2 = std::__cxx11::basic_string<char>]'
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:518:67: error: no match for 'operator+' (operand types are 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'} and 'const char [25]')
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:578:49: error: conversion from 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'} to non-scalar type 'const std::string' {aka 'const std::__cxx11::basic_string<char>'} requested
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:824:49: error: conversion from 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'} to non-scalar type 'const std::string' {aka 'const std::__cxx11::basic_string<char>'} requested
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:963:65: error: no match for 'operator+' (operand types are 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'} and 'const char [23]')
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:964:65: error: no match for 'operator+' (operand types are 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'} and 'const char [23]')
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:965:67: error: no match for 'operator+' (operand types are 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'} and 'const char [25]')
external/grpc-java+/compiler/src/java_plugin/cpp/java_generator.cpp:1294:26: error: no match for 'operator+' (operand types are 'google::protobuf::internal::DescriptorStringView' {aka 'std::basic_string_view<char>'} and 'const char [5]')
ERROR: /home/vorburger/git/github.com/enola-dev/enola/java/dev/enola/cli/BUILD:105:12 Building java/dev/enola/cli/tests.jar (4 source files) failed: (Exit 1): gcc failed: error executing CppCompile command (from target @@grpc-java+//compiler:grpc_java_plugin) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 115 arguments skipped)

PS

#19558, pretty please? @alexeagle @jschaf The constant protoc rebuilding, and running into this kind of error, is the biggest issue with using Protobuf with Bazel.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions