Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Failure to build with "no matching function for call to 'StrongPointer()'" #16868

Closed
veblush opened this issue May 16, 2024 · 2 comments
Assignees
Labels

Comments

@veblush
Copy link
Contributor

veblush commented May 16, 2024

What version of protobuf and what language are you using?

Protobuf commit 9f40411

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

Linux Debian 11 using Docker

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

gcc 12

What did you do?

Build protoc using cmake

What did you expect to see

Successful build

What did you see instead?

Build failure with log

[ 53%] Building CXX object third_party/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/extension_set_heavy.cc.o
In file included from /var/local/git/grpc/third_party/protobuf/src/google/protobuf/extension_set.h:34,
                 from /var/local/git/grpc/third_party/protobuf/src/google/protobuf/descriptor.h:56,
                 from /var/local/git/grpc/third_party/protobuf/src/google/protobuf/compiler/parser.h:24,
                 from /var/local/git/grpc/third_party/protobuf/src/google/protobuf/compiler/parser.cc:14:
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h: In instantiation of 'void google::protobuf::internal::StrongReferenceToType() [with T = google::protobuf::UninterpretedOption]':
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/message_lite.h:923:37:   required from 'const T* google::protobuf::DownCastToGenerated(const google::protobuf::MessageLite*) [with T = google::protobuf::UninterpretedOption]'
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/message_lite.h:933:29:   required from 'T* google::protobuf::DownCastToGenerated(google::protobuf::MessageLite*) [with T = google::protobuf::UninterpretedOption]'
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/compiler/parser.cc:1568:47:   required from here
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:72:43: error: no matching function for call to 'StrongPointer()'
   72 |   return StrongPointer();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:43:36: note: candidate: 'template void google::protobuf::internal::StrongPointer(T*)'
   43 | inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) {
      |                                    ^~~~~~~~~~~~~
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:43:36: note:   template argument deduction/substitution failed:
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:72:43: error: wrong number of template arguments (2, should be 1)
   72 |   return StrongPointer();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:43:36: note: provided for 'template void google::protobuf::internal::StrongPointer(T*)'
   43 | inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) {
      |                                    ^~~~~~~~~~~~~
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:54:36: note: candidate: 'template void google::protobuf::internal::StrongPointer()'
   54 | inline PROTOBUF_ALWAYS_INLINE void StrongPointer() {
      |                                    ^~~~~~~~~~~~~
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:54:36: note:   template argument deduction/substitution failed:
/var/local/git/grpc/third_party/protobuf/src/google/protobuf/port.h:72:43: error: could not convert template argument 'ptr' from 'const google::protobuf::UninterpretedOption& (* const)()' to 'const google::protobuf::UninterpretedOption& (* const)()'
   72 |   return StrongPointer();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

Anything else we should know about your project / environment

  • You can check the PR catching this issue; [Deps] Protobuf at head grpc/grpc#36626
  • This test is running under this docker image; us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_artifact_protoc_aarch64:be8fc962f6a27ce976abecbda3dd02be4be5683d@sha256:a0f6b544c1b2fa75f73b26cb28281917153304e9df2789e93de0732494e6b651
@veblush veblush added the untriaged auto added to all issues by default when created. label May 16, 2024
@zhangskz zhangskz added c++ and removed untriaged auto added to all issues by default when created. labels May 16, 2024
@guldeMNI
Copy link

guldeMNI commented May 17, 2024

DEBUG: /home/mnidev/.cache/bazel/_bazel_mnidev/3c3a08606d72aa32889b958d96f38c5b/external/system_ruby/bundle.bzl:3:10: WARNING: no system ruby found for bundle
INFO: Analyzed 2 targets (173 packages loaded, 2259 targets configured).
ERROR: /home/mnidev/work/latest/protobuf/src/google/protobuf/compiler/BUILD.bazel:35:11: Compiling src/google/protobuf/compiler/parser.cc failed: (Exit 1): gcc failed: error executing CppCompile command (from target //src/google/protobuf/compiler:importer) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++14' -MD -MF ... (remaining 55 arguments skipped)

Seeing this same issue. Think before commiting to main a CI test would have caught.
system:
C++
g++ (Ubuntu 11.4.0-1ubuntu122.04) 11.4.0
gcc (Ubuntu 11.4.0-1ubuntu1
22.04) 11.4.0
seems like compiler template issue - saw some notes on fixing this const pointer issue.

ERRORS:
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/protobuf_lite/google/protobuf/message_lite.h:930:37: required from 'const T* google::protobuf::DownCastToGenerated(const google::protobuf::MessageLite*) [with T = google::protobuf::UninterpretedOption]'
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/protobuf_lite/google/protobuf/message_lite.h:940:29: required from 'T* google::protobuf::DownCastToGenerated(google::protobuf::MessageLite*) [with T = google::protobuf::UninterpretedOption]'
src/google/protobuf/compiler/parser.cc:1568:47: required from here
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:72:43: error: no matching function for call to 'StrongPointer<const google::protobuf::UninterpretedOption& (* const)(), ptr>()'
72 | return StrongPointer<decltype(ptr), ptr>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:43:36: note: candidate: 'template void google::protobuf::internal::StrongPointer(T*)'
43 | inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) {
| ^~~~~~~~~~~~~
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:43:36: note: template argument deduction/substitution failed:
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:72:43: error: wrong number of template arguments (2, should be 1)
72 | return StrongPointer<decltype(ptr), ptr>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:43:36: note: provided for 'template void google::protobuf::internal::StrongPointer(T*)'
43 | inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) {
| ^~~~~~~~~~~~~
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:54:36: note: candidate: 'template<class T, T ptr> void google::protobuf::internal::StrongPointer()'
54 | inline PROTOBUF_ALWAYS_INLINE void StrongPointer() {
| ^~~~~~~~~~~~~
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:54:36: note: template argument deduction/substitution failed:
bazel-out/k8-fastbuild/bin/src/google/protobuf/_virtual_includes/port/google/protobuf/port.h:72:43: error: could not convert template argument 'ptr' from 'const google::protobuf::UninterpretedOption& (* const)()' to 'const google::protobuf::UninterpretedOption& (* const)()'
72 | return StrongPointer<decltype(ptr), ptr>();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

deannagarcia pushed a commit to deannagarcia/protobuf that referenced this issue Jun 20, 2024
Some versions of gcc seem to advertise __cpp_nontype_template_args but not
support the argument in some cases.
Only attempt the template parameter if we are using the optimized .reloc
approach.

Fixes protocolbuffers#16868

PiperOrigin-RevId: 634787159
zhangskz pushed a commit that referenced this issue Jul 1, 2024
Some versions of gcc seem to advertise __cpp_nontype_template_args but not
support the argument in some cases.
Only attempt the template parameter if we are using the optimized .reloc
approach.

Fixes #16868

PiperOrigin-RevId: 634787159
@Mizux
Copy link
Contributor

Mizux commented Jul 8, 2024

For the record:
gcc 11.4.0: Fail
gcc 13.2.0: Pass

ref: https://repology.org/project/gcc/badges

template <typename T>
inline PROTOBUF_ALWAYS_INLINE void StrongReferenceToType() {
constexpr auto ptr = T::template GetStrongPointerForType<T>();
#if defined(__cpp_nontype_template_args) && \
__cpp_nontype_template_args >= 201411L
// We can only use `ptr` as a template parameter since C++17
return StrongPointer<decltype(ptr), ptr>();
#else
return StrongPointer(ptr);
#endif
}

wasphin added a commit to wasphin/brpc that referenced this issue Nov 18, 2024
After using offical boost 1.83.0[1], [email protected] are required,
which, in turn, requires Protobuf v27.0.

Protobuf v27.0 is not compatible with GCC less than 13[2].

[1] apache#2789
[2] protocolbuffers/protobuf#16868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants